wilsonpage wilsonpage - 1 year ago 117
Javascript Question

Partial include paths in mustache.js

I am trying to include a partial inside my template from within a directory.

This works:


This doesn't:



Any location other than a sibling doesn't seem to be picked up. Is this normal?

Answer Source

header, inc/header, and ../header are just names of keys in the partials object passed in at rendering time that have values of the partial text

var tmpl = "{{>header}} {{>inc/header}} {{>../header}}",
    data = {},
partials = {
  header : "<header>example</header>",
  'inc/header' : "<header>xmpl</header>",
  '../header' : "whatever"
html = Mustache.render(tmpl, data, partials);


See here on jsFiddle http://jsfiddle.net/maxbeatty/CWKHe/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download