Skip to content

Commit b9ad292

Browse files
art-template-node
1 parent 4385e0e commit b9ad292

File tree

8 files changed

+304
-0
lines changed

8 files changed

+304
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<script src="./template-web.js"></script>
2+
3+
<div id="content"></div>
4+
5+
<script id="test" type="text/html">
6+
{{if isAdmin}}
7+
<h1>{{title}}</h1>
8+
<ul>
9+
{{each list value i}}
10+
<li>索引 {{i + 1}} {{value}}</li>
11+
{{/each}}
12+
</ul>
13+
{{/if}}
14+
{{$data}}
15+
</script>
16+
17+
<script>
18+
var data = {
19+
title: '基本例子',
20+
isAdmin: true,
21+
list: ['文艺', '博客', '摄影', '电影', '民谣', '旅行', '吉他']
22+
};
23+
var html = template('test', data);
24+
document.getElementById('content').innerHTML = html;
25+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{if isAdmin}}
2+
<h1>{{title}}</h1>
3+
<ul>
4+
{{each list value i}}
5+
<li>索引 {{i + 1}} :{{value}}</li>
6+
{{/each}}
7+
</ul>
8+
{{/if}}
9+
{{$data}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// npm install art-template --save
2+
// 安装 vscode 相关插件
3+
4+
const path = require('path');
5+
const template = require('art-template');
6+
const data = {
7+
title: '基本例子',
8+
isAdmin: true,
9+
list: ['文艺', '博客', '摄影', '电影', '民谣', '旅行', '吉他']
10+
};
11+
const html = template(path.resolve(__dirname, 'index.art'), data);
12+
console.log(html);

04-常用功能/04-js模板引擎/artTemplate/04-webpack版本/package-lock.json

+243
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "art-template-demo",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "main.js",
6+
"scripts": {
7+
"start": "node main.js",
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"art-template": "^4.13.2"
14+
}
15+
}

0 commit comments

Comments
 (0)