Platinum Partner

Access Parent Data Array From Nested JQuery Templates







// underscore.js mixin to find list class, not relevant to finding the index in jquery.tmpl, but useful otherwise.
_.mixin({
  indexClass: function(index, length) {
    var result;
    result = index % 2 === 0 ? "even" : "odd";
    if (index === 0) {
      result += " first";
    } else if (index === length - 1) {
      result += " last";
    }
    return result;
  }
});

columns = []
columns.push({title: "First Column", position: 0, terms: [{key: "One", value: 1, position: 0}, {key: "Two", value: 2, position: 1}]});
columns.push({title: "Middle Column", position: 1, terms: [{key: "A", value: "a", position: 0}, {key: "B", value: "b", position: 1}]});
columns.push({title: "Last Column", position: 2, terms: [{key: "X", value: "x", position: 0}, {key: "Y", value: "y", position: 1}]});
$("#section-template").tmpl({title: "Managing Lists in jQuery.tmpl" columns:columns}).appendTo("body")
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}