Replies: 1 comment
-
You can use Partial Contexts for achieving this: https://handlebarsjs.com/guide/partials.html#partial-contexts
Example |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I have a question that I am bringing here only because I couldn't find documentation or other references to this.
Is it possible to overwrite a nested data parameter for a partial (
{{> partial user.name='Laura'}}
)? Or is this something that requires a helper?Js Fiddle example
Code that fails to compile
var data = { "user": { "name": "Bob" } } Handlebars.registerPartial("user_partial", "{{user.name}}"); // Overwrite the "user.name" parameter when rendering the partial var template = Handlebars.compile( "My name is {{> user_partial user[name]='Laura'}}" // throws compiler error ); document.getElementById('output').innerHTML = template(data);
Desired output
Thanks
Beta Was this translation helpful? Give feedback.
All reactions