Skip to content

Instantly share code, notes, and snippets.

@benhowdle89
Created May 22, 2013 14:55
Show Gist options
  • Save benhowdle89/5628170 to your computer and use it in GitHub Desktop.
Save benhowdle89/5628170 to your computer and use it in GitHub Desktop.
var model.LineItems = [blah, blah, blah]; // pseudo array declaration
var projects = BB.Collection; // pseudo collection declaration
model.LineItems[1].ProjectNumber = 'xyz'; // an example value for a line item
//in view render function
for (x in model.LineItems) {
model.LineItems[x].projects = projects;
}
//html in template
<select id="quotesProject">
{{#select model.ProjectNumber}}
{{#each projects}}
<option value="{{Number}}">{{Name}}</option>
{{/each}}
{{/select}}
</select>
@jackfranklin
Copy link

You could render one and dump it inside another.

If you use {{{ foo }}} in Handlebars it will dump text out and not escape it.

@jackfranklin
Copy link

Doing it that way does at least mean:

  • not rendering the same projects for every single model
  • no need to do the extra work adding the property to the model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment