In general, HTML and JavaScript are segregated in frameworks by defining UI or a view to represent their mutable data, which normally is a template language and/or a display logic interpreter. The following is some jQuery code:
<html> <head> <title>Just an example</title> </head> <body> <div id="my-awesome-app"> <!-- Here go my rendered template --> </div> <script id="my-list" type="text/html"> <ul> {{each items}} <li> ${name} </li> {{/each}} </ul> </script> </body> </html>
The script
element represents a template component that will be rendered in the my-awesome-app div
element. The code here is a JavaScript file that pushes data to that template and asks jQuery to do the job and render the UI:
$("#my-list").tmpl(serverData).appendTo("#my-my-awesome-app");
Whenever you want to put some...