Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jumoel opened this issue Dec 28, 2014 · 4 comments · Fixed by #941
Closed

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

jumoel opened this issue Dec 28, 2014 · 4 comments · Fixed by #941
Assignees
Labels
Milestone

Comments

@jumoel
Copy link

jumoel commented Dec 28, 2014

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?

@jumoel jumoel changed the title Partials doesn't work with subexpressions (like they should?) Partials dont work with subexpressions (like they should?) Dec 28, 2014
@jumoel jumoel changed the title Partials dont work with subexpressions (like they should?) Partials don't work with subexpressions (like they should?) Dec 28, 2014
@kpdecker
Copy link
Collaborator

kpdecker commented Jan 8, 2015

The sexpr object that you are seeing in the yy file is not the same thing as the nested () subexpression call. It's probably not the best name as this is used for mustache evaluation, subexpression evaluation (as the user sees them) and as of 3.0, partial parsing.

I need to think about it a bit, but I don't see anything inherently wrong with allowing dynamic partial evaluation as you are trying here.

@kpdecker kpdecker added this to the 3.0 milestone Jan 8, 2015
@kpdecker kpdecker self-assigned this Jan 8, 2015
@waynedpj
Copy link

waynedpj commented Jan 8, 2015

👍 for dynamic partial evaluation, e.g. as in dust.js
thanks

kpdecker added a commit that referenced this issue Jan 18, 2015
Uses the subexpression syntax to allow for dynamic partial lookups. Ex:

```
{{> (helper) }}
```

Fixes #933
@kpdecker
Copy link
Collaborator

Closing in favor of #941

@jumoel
Copy link
Author

jumoel commented Jan 23, 2015

Awesome! 👍

kpdecker added a commit that referenced this issue Apr 16, 2015
Converts the tool chain to use babel, eslint, and webpack vs. the previous proprietary solutions.

Additionally begins enforcing additional linting concerns as well as updates the code to reflect these rules.

Fixes #855
Fixes #933
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants