How to outsource a template js to a different file when using Handlebars.js

前端 未结 2 2108
再見小時候
再見小時候 2020-12-17 04:15

I have this template script



        
2条回答
  •  一生所求
    2020-12-17 04:58

    You can use ajax to load the template file.

    With jQuery:

    $.get("user_template.js", function(template_text){
        var template = Handlebars.compile(template_text);
        // more things
    });
    

提交回复
热议问题