Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to keep html templates?

I have a single page app. Currently my templates stored in index.html e.g.

 <script id="button" type="text/html">
    <a class="button" href="#" id="${id}">
       ${value}
    </a>
 </script>

Is it a best practice to store them in such way? I've found jQuery templates - where should I put them? but there is no acceptable answer.

like image 474
Plastic Rabbit Avatar asked May 31 '11 13:05

Plastic Rabbit


People also ask

What are HTML templates used for?

The <template> HTML element is a mechanism for holding HTML that is not to be rendered immediately when a page is loaded but may be instantiated subsequently during runtime using JavaScript. Think of a template as a content fragment that is being stored for subsequent use in the document.


1 Answers

You are doing it right. There is no need to add unnecessary complexity to a single-page app, according to the KISS principle:

Most systems work best if they are kept simple rather than made complex; therefore simplicity should be a key goal in design and unnecessary complexity should be avoided.

like image 110
George Cummins Avatar answered Nov 11 '22 08:11

George Cummins