Skip to content

Passing Nested Data Parameters to Partials #1698

@ldrummond

Description

@ldrummond

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions