admin管理员组

文章数量:1323723

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?

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?

Share Improve this question edited Apr 19, 2016 at 11:46 Alex 8,3137 gold badges54 silver badges80 bronze badges asked Dec 9, 2011 at 14:05 wilsonpagewilsonpage 17.6k23 gold badges105 silver badges150 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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/maxbeatty/CWKHe/

本文标签: javascriptPartial include paths in mustachejsStack Overflow