插件的用途:将匹配的第一个元素作为模板,渲染获取的数据。

只读的渲染

API: $( "#template" ).tmpl( data ).appendTo( "#list");

加载数据

DATA:


var movies = [
        { Name: "The Red Violin", ReleaseYear: "1998" },
        { Name: "Eyes Wide Shut", ReleaseYear: "1999" },
        { Name: "The Inheritance", ReleaseYear: "1976" }
    ];

HTML:

<script id="movieTemplate" type="text/x-jquery-tmpl">
<li><b>${Name}</b> (${ReleaseYear})</li>
</script>
<ul id="movieList"></ul>