From cbbe62965dcef417d9f31f80bb36ff37f95c3c6c Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Tue, 28 Nov 2017 00:20:35 +0530 Subject: [PATCH] fix(include): allow callExpression inside include --- src/Tags/IncludeTag.js | 2 +- test/unit/tags/include.spec.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Tags/IncludeTag.js b/src/Tags/IncludeTag.js index 108568b..7495bed 100644 --- a/src/Tags/IncludeTag.js +++ b/src/Tags/IncludeTag.js @@ -52,7 +52,7 @@ class IncludeTag extends BaseTag { * @return {Array} */ get allowedExpressions () { - return ['Literal', 'Identifier', 'MemberExpression'] + return ['Literal', 'Identifier', 'MemberExpression', 'CallExpression'] } /** diff --git a/test/unit/tags/include.spec.js b/test/unit/tags/include.spec.js index 667bc51..306523c 100644 --- a/test/unit/tags/include.spec.js +++ b/test/unit/tags/include.spec.js @@ -83,4 +83,17 @@ test.group('Tags | Include ', (group) => {

Foo

`) }) + + 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`

User Profile

+

Foo

+ `) + }) })