2011-12-09 14 views
7

में पथ शामिल हैं, मैं एक निर्देशिका के भीतर से अपने टेम्पलेट के अंदर आंशिक शामिल करने की कोशिश कर रहा हूं।आंशिक में mustache.js

यह काम करता है:

{{>header}} 

यह नहीं करता है:

{{>inc/header}} 

{{>../header}} 

किसी भी एक भाई के अलावा किसी अन्य स्थान उठाया जा प्रतीत नहीं होता है। क्या यह सामान्य है?

उत्तर

6

header, inc/header, और ../header partials में चाबियों का सिर्फ नाम समय प्रतिपादन में में पारित वस्तु है कि आंशिक लेख के मूल्यों हैं

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

यहाँ देखें jsFiddle http://jsfiddle.net/maxbeatty/CWKHe/

पर
संबंधित मुद्दे