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 this
<script id="templateName" type="text/x-jsrender" src="thisIsTheTemplate.js"></script>
I will apreciate any commemnts or suggestions.
Thanks
Yes, you can accomplish this (I use this every time).
let’s assume that you have your templates in a
templatefolder and it is called, for example_productDetails.tmpl.htmlin your page you use jQuery
$.get()to pull it and load into the template, like:and you pass an object
itemwitch will contain all 3 properties, like:You can have a nice utilities class to hold all this:
and you can easily call
my.utils.renderExtTemplate(item);