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

Decorator arguments don't work with properties or helpers #1320

Closed
steinerkelvin opened this issue Mar 5, 2017 · 3 comments
Closed

Decorator arguments don't work with properties or helpers #1320

steinerkelvin opened this issue Mar 5, 2017 · 3 comments

Comments

@steinerkelvin
Copy link

Decorators seem to only accept literal arguments. If trying to pass property or sub expression they receive undefined or just fail, respectively.

{{myHelper myVar}}  // works
{{*myDec myVar}} // gives undefined
{{*myDec (lookup . myVar) }}  // crashes

jsfiddle (better if developer console is open)

@mdelbuono
Copy link

I have the same problem.
With me it works as expected if the block contain only one inline decorator. With two it fails.
Did you find a solution?

@mdelbuono
Copy link

I found the problem: the decorator function is executed after var fn = compile(template, options) but before var output = fn(context), therefore the context is not known when the decorator function runs.
The decorator argument options.args refers to the parent block, therefore if you place your decorator inside a child block, it will work. See also this question on StackOverflow.
Hope this helps.

@nknapp
Copy link
Collaborator

nknapp commented May 13, 2017

@KelvinSS Please add a comment if this didn't work out.

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

No branches or pull requests

3 participants