How do I precompile partials for handlebars.js?

后端 未结 7 1266
心在旅途
心在旅途 2021-02-01 03:10

I\'m using handlebars.js and I want to start precompiling everything, but I can\'t seem to find a way to precompile the partials. The majority of my templates are actually parti

7条回答
  •  滥情空心
    2021-02-01 03:53

    I managed to get it working by pre compiling all my partials as templates and then adapting Nathans solution

    // instead of {{> partialName}} use {{partial "templateName"}}
    Handlebars.registerHelper('partial', function (templateName) {
        return new Handlebars.SafeString(JST[templateName](this));
    });
    

    So for me Handlebars.templates became JST when i compiled things, i noticed it in my compiled templates file.

提交回复
热议问题