jQuery Templates メモ

こんな感じで書いていきます。

<html>
<head>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.js"></script>
</head>
<script type="text/javascript">
	$(document).ready(function(){
		var datas = [
		{item: "商品1", price: 1000}
		, {item: "商品2", price: 2000}
		, {item: "商品3", price: 3000}
		, {item: "商品4", price: 4000}
		];
		var tmpl = $("#container-row").tmpl(datas);
		tmpl.appendTo("#container");
	});
</script>
<body>
<p>商品リスト</p>
<ul id="container"></ul>
<script id="container-row" type="text/html"><li>商品名:{{= item }}、値段{{= price }}</li></script>
</body>
</html>