When we were developing the DOM operation, it was no problem with a simple JS application, but what if you needed to manipulate a lot of chunks in my document every time you updated the view? At this time the JS template came in handy.
Source Address: http://rfyiamcool.blog.51cto.com/1030776/1278620
This is an example where we can embed the JSON data in the template as we think it is.
<!
DOCTYPE html>
See this example, we feel very happy it ~ is so. We can get the data from the back end and throw it to the front end without having to write the various "<>" separation symbols.
To traverse the data inside, print out
<script id= "Each-template" type= "Text/x-handlebars-template" >
{{#each people}}
... output person ' s info here ...
{{/each}}}
</script>
Data rendering if data is available
<script id= "Each-template" type= "Text/x-handlebars-template" >
{{#if people}}
... output person ' s info
here ... {{/if}}}
</script>