I use icanhaz.js to create a JS template, and that's great! However, I cannot understand the idea of ​​creating some complex objects, and then repeat them.
Basically, in the header of the template I want to display some basic lines and then iterate the object, but first I need to pre-process this object in another template, as it contains some additional variables.
So it looks like this:
<script id="tmpl_map" type="text/html">
<h4>{{ equipment }}
<h3>{{ number }}</h4>
{{#rows}}
{{.}}
{{/rows}}
</script>
My Javascript code is pretty simple for this:
view = {
equipment: data.active.equipment,
number: data.active.number,
rows: function() {
return function(text, render) {
var rows = [];
_.each(data.map.rows, function(el, index) {
view = { row: el[0], has_split_next: el[1] };
rows.push(ich.map_header(view));
});
return render(rows);
}
}
}
, , , has_split_next HTML. , ,
, , - [object Object].