I have a backbone model like this
var PeopleModel = Backbone.Model.extend({
defaults: {
\"people\": [
{ \"username\": \"alan\", \
I think this is similar to Dave's answer, but perhaps requiring less code:
function partialTemplate(origTemplate, partialValues){
return function(values){
return origTemplate(_.defaults(values, partialValues));
};
}
Example usage:
var t = _.template('<%= val1 %>,<%= val2 %>'); // original template requiring 2 values
var pt = partialTemplate(t, {val1:1}); // partial template with 1 value pre-populated
pt({val2:2}); // returns '1,2'
pt({val2:3}); // returns '1,3'