If you use a logical client-side template engine, such as Transparency , the templates can be embedded in the main HTML, since the templates themselves are valid HTML,
Example:
<div id="template"> <span class="greeting"></span> <span class="name"></span> </div> // Data var hello = { greeting: 'Hello', name: 'world!' }; <div id="template"> <span class="greeting">Hello</span> <span class="name">world!</span> </div>
For templates to be used as widgets, the <div>
container is hidden.
Entering HTML code into Javascript code blocks and Javascript strings is ugly and should be avoided if possible. This is not syntax, and you easily skip errors.
source share