Skip to content

Commit

Permalink
fix(include): allow callExpression inside include
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Nov 27, 2017
1 parent 86d1715 commit cbbe629
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Tags/IncludeTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class IncludeTag extends BaseTag {
* @return {Array}
*/
get allowedExpressions () {
return ['Literal', 'Identifier', 'MemberExpression']
return ['Literal', 'Identifier', 'MemberExpression', 'CallExpression']
}

/**
Expand Down
13 changes: 13 additions & 0 deletions test/unit/tags/include.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,17 @@ test.group('Tags | Include ', (group) => {
<h2> Foo </h2>
`)
})

test('call a function inside include', (assert) => {
const statement = `@include(getFile('includes.user-profile'))`

const template = new Template(this.tags, {}, {}, loader)
const output = template.renderString(statement, {
username: 'Foo',
getFile (input) { return input }
})
assert.equal(output.trim(), dedent`<h1> User Profile </h1>
<h2> Foo </h2>
`)
})
})

0 comments on commit cbbe629

Please sign in to comment.