-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinterpolation.js
86 lines (76 loc) · 1.79 KB
/
interpolation.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const assert = require('assert')
const hv = require('..')
assert.strictEqual(hv(`
<div>{state.foo}</div>
`),
`h('div', null, (state.foo))
`)
assert.strictEqual(hv(`
<div>
{state.bar}
</div>
`),
`h('div', null, (state.bar))
`)
assert.strictEqual(hv(`
<div>
<span>The value of bar is {state.bar}!</span>
</div>
`),
`h('div', null, h('span', null, 'The value of bar is ' + (state.bar) + '!'))
`)
assert.strictEqual(hv(`
<div>
<span>{state.a}{state.c}</span>
</div>
`),
`h('div', null, h('span', null, (state.a) + (state.c)))
`)
assert.strictEqual(hv(`
<div>
<span>{state.a} {state.b} {state.c}</span>
</div>
`),
`h('div', null, h('span', null, (state.a) + ' ' + (state.b) + ' ' + (state.c)))
`)
assert.strictEqual(hv(`
<div>
<span>a is {state.a}, b is {state.b} and c is {state.c}</span>
</div>
`),
`h('div', null, h('span', null, 'a is ' + (state.a) + ', b is ' + (state.b) + ' and c is ' + (state.c)))
`)
assert.strictEqual(hv(`
<div id='id'>{state.firstName} {state.lastName}</div>
`),
`h('div', { 'id': 'id' }, (state.firstName) + ' ' + (state.lastName))
`)
assert.strictEqual(hv(`
<div>
My name is Elizabeth II.
I am your Queen.
</div>
`),
`h('div', null, 'My name is Elizabeth II.\\
I am your Queen.')
`)
assert.strictEqual(hv(`
<div>
<a href="http://www.google.co.uk?q={state.query}"></a>
My name is {state.name} my age is {state.age} and I live at {state.address}
</div>
`),
`h('div', null, [
h('a', { 'href': 'http://www.google.co.uk?q=' + (state.query) }),
'My name is ' + (state.name) + ' my age is ' + (state.age) + ' and I live at ' + (state.address)
])
`)
assert.strictEqual(hv(`
<div>
My name is {state.name} my age is {state.age}.
I live at {state.address}
</div>
`),
`h('div', null, 'My name is ' + (state.name) + ' my age is ' + (state.age) + '.\\
I live at ' + (state.address))
`)