- 创建一个文件夹 (hello)
- 在hello中 初始化包 (在cmd中输入命令 )
npm init
- 创建一个index .js文件
- 在hello文件夹下 执行
npm install art-template --save
- 在index文件中写渲染模板
var template = require('art-template');
var html = template(__dirname + '/tpl.art', {
user: {
name: 'aui',
age:18
}
});
console.log(html);
6.创建一个和上面代码第二行中相同的文件‘ tpl.art’
文件里面写标准语法
{{if user}}
<h2>{{user.name}}</h2>
<h2>{{user.age}}</h2>
{{/if}}
7.运行包 node .