art-template基本用法例子

<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>art-template例子</title>
<script src="art-template.js"></script>
</head>
 
<body>
<div id="content"></div>
<script id="template" type="text/html">
{{if isAdmin}}
 
<h1>{{title}}</h1>
<ul>
    {{each list value i}}
        <li>索引 {{i + 1}} :{{value}}</li>
    {{/each}}
</ul>
 
{{/if}}
{{$data}}
</script>
 
<script>
 
 
var data = {
	title: 'ORM框架',
	isAdmin: true,
	list: ['Hibernate', 'Mybatis', 'Bee', 'Honey']
};
var html = template('template', data);
document.getElementById('content').innerHTML = html;
</script>
</body>
</html>

原文地址:https://www.cnblogs.com/pansidong/p/13224961.html