BorisMoore / jsrender

A lightweight, powerful and highly extensible templating engine. In the browser or on Node.js, with or without jQuery.
http://www.jsviews.com
MIT License
2.67k stars 339 forks source link

template content in external files #352

Closed erfurtjohn closed 4 years ago

erfurtjohn commented 4 years ago

Is it possible to put the template content into an external file like templates/table.tpl or something similiar?

BorisMoore commented 4 years ago

If you are loading jsrender in the browser, then since the javascript in the browser does not have access to the file system, you can't load template files from the client. But you can access template files on the server, using $.get or $.getScript, as shown here: https://www.jsviews.com/#compiletmpl@fromserver

If you are running jsrender on the server, (Node.js) then yes. See https://www.jsviews.com/#node/filetmpls and also https://github.com/BorisMoore/jsrender-node-starter.

erfurtjohn commented 4 years ago

Thank you for the advice!