Skip to content

Commit 059f1df

Browse files
1 parent 9f93d83 commit 059f1df

File tree

8 files changed

+41
-3
lines changed

8 files changed

+41
-3
lines changed

lib/brackets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var R_MLCOMMS = /\/\*[^*]*\*+(?:[^*\/][^*]*\*+)*\//g
2020
* @const {RegExp}
2121
* @static
2222
*/
23-
var R_STRINGS = /"[^"\\]*(?:\\[\S\s][^"\\]*)*"|'[^'\\]*(?:\\[\S\s][^'\\]*)*'/g
23+
var R_STRINGS = /"[^"\\]*(?:\\[\S\s][^"\\]*)*"|'[^'\\]*(?:\\[\S\s][^'\\]*)*'|`[^`\\]*(?:\\[\S\s][^`\\]*)*`/g
2424

2525
/**
2626
* The {@link module:brackets.R_STRINGS|R_STRINGS} source combined with sources of

lib/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ function compileHTML (html, opts, pcex) {
337337
* 2016-01-18: rewritten to capture only the method name (performant)
338338
* @const {RegExp}
339339
*/
340-
var JS_ES6SIGN = /^[ \t]*(((?:async)\s*)?([$_A-Za-z][$\w]*))\s*\([^()]*\)\s*{/m
340+
var JS_ES6SIGN = /^[ \t]*(((?:async|\*)\s*)?([$_A-Za-z][$\w]*))\s*\([^()]*\)\s*{/m
341341

342342
/**
343343
* Regex for remotion of multiline and single-line JavaScript comments, merged with

src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ function compileHTML (html, opts, pcex) {
368368
* 2016-01-18: rewritten to capture only the method name (performant)
369369
* @const {RegExp}
370370
*/
371-
var JS_ES6SIGN = /^[ \t]*(((?:async)\s*)?([$_A-Za-z][$\w]*))\s*\([^()]*\)\s*{/m
371+
var JS_ES6SIGN = /^[ \t]*(((?:async|\*)\s*)?([$_A-Za-z][$\w]*))\s*\([^()]*\)\s*{/m
372372

373373
/**
374374
* Regex for remotion of multiline and single-line JavaScript comments, merged with

test/specs/expect/es6-async.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ riot.tag2('async', '<h1>async test</h1>', '', '', function(opts) {
66
await new Promise((resolve) =>{setTimeout(resolve,2000)});
77
console.log("done");
88
}.bind(this)
9+
this.bar =* function(){
10+
yield baz
11+
}.bind(this)
912
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
riot.tag2('es6-template-strings', '<h1>{message}</h1>', '', '', function(opts) {
2+
this.message = `http://www.riotjs.com/guide`
3+
4+
this.text = `
5+
The message is:
6+
${ message }
7+
8+
${ [1,2,3].map(function(n) { return n }) }
9+
${ [1,2,3].map(n => n) }
10+
`
11+
});

test/specs/fixtures/es6-async.tag

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@
1010
await new Promise((resolve) => {setTimeout(resolve,2000)});
1111
console.log("done");
1212
}
13+
14+
* bar() {
15+
yield baz
16+
}
1317
</script>
1418
</async>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<es6-template-strings>
2+
<h1>{ message }</h1>
3+
4+
<script>
5+
this.message = `http://www.riotjs.com/guide`
6+
7+
this.text = `
8+
The message is:
9+
${ message }
10+
11+
12+
${ [1,2,3].map(function(n) { return n }) }
13+
${ [1,2,3].map(n => n) }
14+
`
15+
</script>
16+
</es6-template-strings>

test/specs/tag.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ describe('Compile tags', function () {
7979
testFile('es6-import')
8080
})
8181

82+
it('Es6 template strings can be properly parsed', function () {
83+
testFile('es6-template-strings')
84+
})
85+
8286
it('Support short cut async functions', function () {
8387
testFile('es6-async')
8488
})

0 commit comments

Comments
 (0)