Handlebars' templates depending on tie's constraints.
// Handlebar (compiled) template.
var source = tie("<p>Hello, my name is {{name}}. I am from {{hometown}}. I have " +
"{{kids.length}} kids:</p>" +
"<ul>{{#kids}}<li>{{name}} is {{age}}</li>{{/kids}}</ul>");
var template = tie(function(){
return handlebars.compile(source.get());
});
// Template's argument.
var data = tie({
"name": "Alan",
"hometown": "Somewhere, TX",
"kids": [
{"name": "Jimmy", "age": "12"},
{"name": "Sally", "age": "4"}
]
});
// Constraint on the result of the application of data on the template template.
var result = tieHandlebars(template, data);
- The template nor the data does not have to be constraints. One may directly provide their value to
tieHandlebars
. - Non compiled template are not supported. Ideally, you should precompile your templates.