Browse Source

render identifiers inside template literals

gh-953
Rich-Harris 8 years ago
parent
commit
8446b06e8d
  1. 3
      src/ast/nodes/TemplateLiteral.js
  2. 3
      test/function/identifiers-in-template-literals/_config.js
  3. 7
      test/function/identifiers-in-template-literals/a.js
  4. 7
      test/function/identifiers-in-template-literals/b.js
  5. 5
      test/function/identifiers-in-template-literals/main.js

3
src/ast/nodes/TemplateLiteral.js

@ -1,7 +1,8 @@
import Node from '../Node.js';
export default class TemplateLiteral extends Node {
render ( code ) {
render ( code, es ) {
code.indentExclusionRanges.push([ this.start, this.end ]);
super.render( code, es );
}
}

3
test/function/identifiers-in-template-literals/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'identifiers in template literals are rendered correctly'
};

7
test/function/identifiers-in-template-literals/a.js

@ -0,0 +1,7 @@
function x ( keypath ) {
return 'a';
}
export default function a () {
return x();
}

7
test/function/identifiers-in-template-literals/b.js

@ -0,0 +1,7 @@
function x ( name ) {
return 'b';
}
export default function b () {
return `${x()}`;
}

5
test/function/identifiers-in-template-literals/main.js

@ -0,0 +1,5 @@
import a from './a.js';
import b from './b.js';
assert.equal( a(), 'a' );
assert.equal( b(), 'b' );
Loading…
Cancel
Save