javascript - Can I load partials from another file in Mustache.js? -


i'm trying load in partials separate file while using mustache.js it's proven difficult. php implementation makes easy, not in js side.

i've gone through docs , can't find related this, using object partial instead of file.

here's sort of psuedocode explain i'm trying do.

$.mustache.load('/mustaches.php', function () {      var item = { thing: 'one' };     var partial = 'partials/actions.mustache';      $('.container').mustache(         'main_mustache',         {item: item},         partial     );  }); 

so, i'd able load secondary file partial include template used don't have duplicate code across different templates use.

with blaze can import template {{> templatename}} doesn't seem quite easy mustache.js.

if isn't possible mustache, other libraries recommend?

you load both templates mustache, , pass 1 of them (the partial) 1 should render partial. aware in order make work, in mustache want render partial, variable name should enclosed in triple curly bracers in order tell mustache should html:

<div>     <h1>this title</h1>     {{{partial}}} </div> 

and then:

$('.container').mustache(     'main_mustache',     {item: item, partial: partial}, ); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -