Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partial include paths in mustache.js

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

This works:

{{>header}}

This doesn't:

{{>inc/header}}

{{>../header}}

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

like image 840
wilsonpage Avatar asked Dec 09 '11 14:12

wilsonpage


1 Answers

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);

document.write(html);

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

like image 135
maxbeatty Avatar answered Oct 01 '22 14:10

maxbeatty