Template (id, data) method:
ID: Must pass, the ID of the rendering template.
Data: Optional, one object.
Return: Pass data-> render complete HTML code, do not pass data-> a render function.
Example one is as follows:
<DivID= "Content"></Div><Scriptsrc=".. /js/template.js "type= "Text/javascript"CharSet= "Utf-8"></Script><Scripttype= "text/html"ID= "Test_tmpl"> <ul>{Each list as value I}}<Li>Index {{i+ 1} }: {{value}}</li> {{/Each }} </ul></Script><Scripttype= "Text/javascript"> varData={title:"label", list: ["Literature", "Blog", "Photography", "movie", "Ballad", "Travel", "Guitar"] }; varHTML=Template ("Test_tmpl", data); document.getElementById ("content"). InnerHTML=html;</Script>
Example two is as follows:
<DivID= "Content"></Div><Scriptsrc=".. /js/template.js "type= "Text/javascript"CharSet= "Utf-8"></Script><Scripttype= "text/html"ID= "Test_tmpl"> <ul>{Each list as value I}}<Li>Index {{i+ 1} }: {{value}}</li> {{/Each }} </ul></Script><Scripttype= "Text/javascript"> varData={title:"label", list: ["Literature", "Blog", "Photography", "movie", "Ballad", "Travel", "Guitar"] }; varHTML=Template ("Test_tmpl"); document.getElementById ("content"). InnerHTML=HTML (data);</Script>
JavaScript template engine Arttemplate.js--template () method