<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="js/jquery-1.11.0.js"></script>
<script type="text/javascript" src="js/doT.js" ></script>
</head>
<body>
<div id="myInfo"></div>
<!-- 模板 -->
<script id="myInfoTmpl" type="text/x-dot-template">
<div>Hi {{=it.name}}</div>
<div>{{=it.age}}</div>
</script>
<script>
var userData = {"name": 'zhangsan', "age": 12};
var interText = doT.template($('#myInfoTmpl').text());
$('#myInfo').html(interText(userData));
</script>
</body>
</html>
github地址:https://github.com/olado/doT