Store a jsRender template in a separate js file

后端 未结 5 631
天涯浪人
天涯浪人 2020-12-14 19:24

Is it possible to store a jsRender template in a separate file?

I want to store it in a separate file and make a reference of it in my page.

something like t

5条回答
  •  旧巷少年郎
    2020-12-14 19:37

    I recently ran into this problem myself. After looking through the jsRender code, and studying other javascript libraries, I decided to write my own library that would simplify loading external templates so that one could attach templates to a html page using the tag and render them by simply including the .js file. If you would like to check it out, I have posted the code on github with examples:

    https://github.com/stevenmhunt/tmpl.loader

    This library works with jsRender, as well as any code capable of processing a template.

    Enjoy!

提交回复
热议问题