Skip to content

Partials don't work with subexpressions (like they should?) #933

@jumoel

Description

@jumoel

It seems to me, that according to src/handlebars.yy, the partial tag ({{> ...}}) should support subexpressions: OPEN_PARTIAL sexpr CLOSE ...

But with a freshly checked out handlebars repository, and testme.js in the same folder:

// testme.js
var Handlebars = require('./');

var source = "{{> (subexpr)}}";
Handlebars.registerPartial('partial', 'this is a partial')
var template = Handlebars.compile(source);

var data = { "subexpr": "partial" };
var result = template(data);

node testme.js gives:

/tmp/handlebars.js/dist/cjs/handlebars/compiler/parser.js:124
    throw new Error(str);
          ^
Error: Parse error on line 1:
{{> (subexpr)}}
----^
Expecting 'STRING', 'NUMBER', 'ID', 'DATA', got 'OPEN_SEXPR'
    at Object.parseError (/tmp/handlebars.js/dist/cjs/handlebars/compiler/parser.js:124:11)
    at Object.parse (/tmp/handlebars.js/dist/cjs/handlebars/compiler/parser.js:176:22)
    at HandlebarsEnvironment.parse (/tmp/handlebars.js/dist/cjs/handlebars/compiler/base.js:25:30)
    at compileInput (/tmp/handlebars.js/dist/cjs/handlebars/compiler/compiler.js:448:19)
    at ret (/tmp/handlebars.js/dist/cjs/handlebars/compiler/compiler.js:457:18)
    at Object.<anonymous> (/tmp/handlebars.js/testme.js:8:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

Is this a bug or a comprehension-error on my part?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions