you can load this template with ajax.
<script>
var movies = [
{ Name: "The Red Violin", ReleaseYear: "1998", Director: "Fran?ois Girard" },
{ Name: "Eyes Wide Shut", ReleaseYear: "1999", Director: "Stanley Kubrick" },
{ Name: "The Inheritance", ReleaseYear: "1976", Director: "Mauro Bolognini" }
];
$.get("templates/movieTemplate.html", function(data, textStatus, XMLHttpRequest){
var markup = data; //"<tr><td colspan='2'>${Name}</td><td>Released: ${ReleaseYear}</td><td>Director: ${Director}</td></tr>"
/* Compile markup string as a named template */
$.template( "movieTemplate", markup );
/* Render the named template */
$.tmpl( "movieTemplate", movies ).appendTo( "#movieList" );
});
</script>
You can add now the localstorage logic or an array for the loaded templates if you want to load any template only once.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…