Created
May 22, 2013 14:55
-
-
Save benhowdle89/5628170 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Can you nest templates in Handlebars?
@jackfranklin: You can in Meteor and it's such a dream!
You could render one and dump it inside another.
If you use {{{ foo }}}
in Handlebars it will dump text out and not escape it.
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
So you have a collection of models, each of which share the same
projects
collection?In this case I'd be tempted to extract this into a separate template:
And only render it once, with the
projects
collection, and then drop it into the model template.Maybe?