artemplate
896 ワード
1、html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>compile-demo</title>
</head>
<body>
<h1> javascript </h1>
<div id="content"></div>
<script src="../lib/require.js" data-main="arttemplateTest"></script>
</body>
</html>
2、jsrequire(['template'], function (template) {
console.log(template.compile);
var source = '<ul>' + '{{each list as value i}}' + '<li> {{i + 1}} :{{value}}</li>' + '{{/each}}' + '</ul>';
var render = template.compile(source);
var html = render({
list: [' ', ' ', ' ', ' ', ' ']
});
document.getElementById('content').innerHTML = html;
});