how write text/template in a file and include it to project

112 Views Asked by At

I use script type="text/template" for my project and I use a lot of templates, I want write my template in foreign file and include it to my html

If its possible , what type of file must i use and how must write it ?

1

There are 1 best solutions below

0
On

In a pure JavaScript/HTML environment, you can't easily.

Your choices are:

Use some kind of JavaScript template library

I'm only familiar with Durandal that uses the Knockout engine.

AngularJS seems to be another popular choice.

Most of these packages include far more than just templates and may be overkill.

Use a server-side template package

PHP is a popular server-side tool.

Some HTTP Servers support Server Side Includes, but these are so limited I couldn't actually recommend them.