Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Passing Nested Data Parameters to Partials #1698

Closed
ldrummond opened this issue Jul 9, 2020 · 0 comments
Closed

Passing Nested Data Parameters to Partials #1698

ldrummond opened this issue Jul 9, 2020 · 0 comments

Comments

@ldrummond
Copy link

ldrummond commented Jul 9, 2020

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

My name is Laura

Thanks

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants