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

Template variables overridden by helper #65

Closed
mendezcode opened this issue Jul 7, 2014 · 4 comments
Closed

Template variables overridden by helper #65

mendezcode opened this issue Jul 7, 2014 · 4 comments
Labels

Comments

@mendezcode
Copy link

Hello @zordius

I just noticed the following: If I have a {{term_link}} helper and I also pass term_link in the template named arguments, the value is overridden by the helper.

I consider the variable should be prioritized instead of the helper as long as it is a named argument.

What do you think?

@zordius
Copy link
Owner

zordius commented Jul 7, 2014

  1. Now the priority of tags parsing in lightncandy is compileSection -> compileCustomHelper -> compileVariable . (check the code from line 1232 ~ line 1246) , so these are true now:
    • You can not overwrite build-in helpers by custom helpers, ex: {{#each }}
    • When you use duplicate names on both custom helper and variable , custom helper will be used.
  2. The priority of tags parsing can be changed if we think another way is better.
  3. I think lightncandy should align with handlebars.js behavior. So, I need to write some tests on handlebars.js, then decide the correct order by the testing results.

@mendezcode
Copy link
Author

Yes, it does make sense. Behavior should be aligned with handlebars.js, completely agree.

Variables can be accessed using @root.variable, so I think it can be left as-is, now that I think of it.

@zordius
Copy link
Owner

zordius commented Jul 8, 2014

Based on this test : http://jsfiddle.net/TY8cJ/1/

custom helper > default helper > variable

This behavior will be applied to lightncandy later.

@zordius
Copy link
Owner

zordius commented Jul 9, 2014

After I review the code of lightncandy deeply , the current order is

compileBlockCustomHelper > compileBlockBegin > compileCustomHelper > compileVariable

So the behavior already same with handlebars.js . No more fix required, and close this. Thanks.

@zordius zordius closed this as completed Jul 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants