-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
index.js
55 lines (47 loc) · 1.76 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const assert = require('assert');
const template = require('../src/index');
const defaults = require('../src/compile/defaults');
const path = require('path');
const root = defaults.root;
module.exports = {
before: () => {
console.log('#index');
},
template: {
render: () => {
const html = template(__dirname + '/res/template.file.html', {});
assert.deepEqual('hello world', html);
},
compile: () => {
defaults.root = path.join(__dirname, 'res');
const render = template('template.file.html');
const html = render({});
assert.deepEqual('hello world', html);
defaults.root = root;
},
include: () => {
defaults.root = path.join(__dirname, 'res');
const html = template('index/index.html', { name: 'aui' });
assert.deepEqual(true, html.indexOf('aui') !== -1);
assert.deepEqual(true, html.indexOf('糖饼') !== -1);
defaults.root = root;
},
cache: () => {
template('/index.html', 'hi, <%=value%>.');
const html = template('/index.html', { value: 'aui' });
assert.deepEqual('hi, aui.', html);
},
nestedBlockUseActualValue: () => {
defaults.root = path.join(__dirname, 'res');
const html = template('nested-block/index.art', { hello: 'hello' });
assert.deepEqual('hello', html);
defaults.root = root;
},
nestedBlockUseDefaultValue: () => {
defaults.root = path.join(__dirname, 'res');
const html = template('nested-block/default.art', {});
assert.deepEqual('default', html);
defaults.root = root;
}
}
};