我已經搜索了谷歌上使用John Resig JavaScript Micro-Templating引擎的一個基本例子,但是出來幹了。如何使用John Resig JavaScript Micro-Templating引擎?
我決定把它帶給基礎傢伙。任何人都可以使用這個引擎的簡單例子嗎?我以前從未使用過客戶端模板引擎。
更新:這是完整的HTML文檔。感謝Will。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>John Resig JavaScript Micro-Templating engine</title>
<script src="jquery-1.3.2.js" type="text/javascript"></script>
<script src="MicroTemplates.js" type="text/javascript"></script>
<script type="text/javascript">
//Data
var data = { fname: "fred" };
function onloadFunction() {
var s = $("#biodata").html();
var s1 = tmpl(s, data);
$("#target").html(s1);
}
</script>
<script id="biodata" type="text/html">
<div><%= fname %></div>
</script>
</head>
<body onload="onloadFunction();">
<div id="target">
</div>
</body>
</html>
感謝您的更改。格雷格。 – Tebo 2009-11-21 10:06:53
如果你能提供一個小提琴的鏈接,那將會很好。 – ayjay 2015-09-20 15:44:28