cmstyle 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/app/assets/images/cm_app.ico +0 -0
- data/lib/app/assets/images/cm_app.png +0 -0
- data/lib/app/assets/images/cm_app_30x30.png +0 -0
- data/lib/app/assets/stylesheets/application.css +9 -78
- data/lib/app/views/layouts/_footer.slim +12 -5
- data/lib/app/views/layouts/application.slim +27 -18
- data/lib/assets/images/glyphicons-halflings-white.png +0 -0
- data/lib/assets/images/glyphicons-halflings.png +0 -0
- data/lib/assets/javascripts/bootstrap.js +165 -31
- data/lib/assets/javascripts/prettify.js +0 -0
- data/lib/assets/stylesheets/bootstrap-responsive.css +5 -1
- data/lib/assets/stylesheets/bootstrap.css +335 -189
- data/lib/assets/stylesheets/prettify.css +0 -0
- data/lib/cmstyle.rb +4 -1
- data/lib/cmstyle/navigation_helpers.rb +165 -0
- data/lib/cmstyle/version.rb +1 -1
- metadata +6 -83
- data/lib/app/assets/images/novartis-micro.png +0 -0
- data/lib/app/assets/images/novartis-small.png +0 -0
- data/lib/app/views/cmstyle/_footer.slim +0 -5
- data/lib/app/views/cmstyle/_header.slim +0 -40
- data/lib/app/views/cmstyle/_modals.slim +0 -62
- data/lib/assets/images/8020select.png +0 -0
- data/lib/assets/images/adoptahydrant.png +0 -0
- data/lib/assets/images/apple-touch-icon-114-precomposed.png +0 -0
- data/lib/assets/images/apple-touch-icon-144-precomposed.png +0 -0
- data/lib/assets/images/apple-touch-icon-57-precomposed.png +0 -0
- data/lib/assets/images/apple-touch-icon-72-precomposed.png +0 -0
- data/lib/assets/images/bootstrap-example-carousel.png +0 -0
- data/lib/assets/images/bootstrap-example-fluid.jpg +0 -0
- data/lib/assets/images/bootstrap-example-hero.jpg +0 -0
- data/lib/assets/images/bootstrap-example-marketing-narrow.png +0 -0
- data/lib/assets/images/bootstrap-example-signin.png +0 -0
- data/lib/assets/images/bootstrap-example-starter.jpg +0 -0
- data/lib/assets/images/bootstrap-example-sticky-footer.png +0 -0
- data/lib/assets/images/bootstrap-mdo-sfmoma-01.jpg +0 -0
- data/lib/assets/images/bootstrap-mdo-sfmoma-02.jpg +0 -0
- data/lib/assets/images/bootstrap-mdo-sfmoma-03.jpg +0 -0
- data/lib/assets/images/breakingnews.png +0 -0
- data/lib/assets/images/browser-icon-chrome.png +0 -0
- data/lib/assets/images/browser-icon-firefox.png +0 -0
- data/lib/assets/images/browser-icon-safari.png +0 -0
- data/lib/assets/images/bs-docs-bootstrap-features.png +0 -0
- data/lib/assets/images/bs-docs-masthead-pattern.png +0 -0
- data/lib/assets/images/bs-docs-responsive-illustrations.png +0 -0
- data/lib/assets/images/bs-docs-twitter-github.png +0 -0
- data/lib/assets/images/fleetio.png +0 -0
- data/lib/assets/images/gathercontent.png +0 -0
- data/lib/assets/images/grid-baseline-20px.png +0 -0
- data/lib/assets/images/jshint.png +0 -0
- data/lib/assets/images/kippt.png +0 -0
- data/lib/assets/images/less-logo-large.png +0 -0
- data/lib/assets/images/logo.png +0 -0
- data/lib/assets/images/noise.png +0 -0
- data/lib/assets/images/responsive-illustrations.png +0 -0
- data/lib/assets/images/slide-01.jpg +0 -0
- data/lib/assets/images/slide-02.jpg +0 -0
- data/lib/assets/images/slide-03.jpg +0 -0
- data/lib/assets/images/small-hogan-icon.png +0 -0
- data/lib/assets/images/soundready.png +0 -0
- data/lib/assets/images/stripes.png +0 -0
- data/lib/assets/javascripts/application.js +0 -154
- data/lib/assets/javascripts/bootstrap-affix.js +0 -19
- data/lib/assets/javascripts/bootstrap-alert.js +0 -56
- data/lib/assets/javascripts/bootstrap-button.js +0 -96
- data/lib/assets/javascripts/bootstrap-carousel.js +0 -63
- data/lib/assets/javascripts/bootstrap-collapse.js +0 -88
- data/lib/assets/javascripts/bootstrap-dropdown.js +0 -145
- data/lib/assets/javascripts/bootstrap-modal.js +0 -114
- data/lib/assets/javascripts/bootstrap-phantom.js +0 -21
- data/lib/assets/javascripts/bootstrap-popover.js +0 -107
- data/lib/assets/javascripts/bootstrap-scrollspy.js +0 -31
- data/lib/assets/javascripts/bootstrap-tab.js +0 -80
- data/lib/assets/javascripts/bootstrap-tooltip.js +0 -153
- data/lib/assets/javascripts/bootstrap-transition.js +0 -13
- data/lib/assets/javascripts/bootstrap-typeahead.js +0 -199
- data/lib/assets/javascripts/compiler.js +0 -348
- data/lib/assets/javascripts/hogan-1.0.5.amd.js +0 -576
- data/lib/assets/javascripts/hogan-1.0.5.common.js +0 -576
- data/lib/assets/javascripts/hogan-1.0.5.js +0 -572
- data/lib/assets/javascripts/hogan-1.0.5.mustache.js +0 -619
- data/lib/assets/javascripts/hogan.js +0 -545
- data/lib/assets/javascripts/index.js +0 -848
- data/lib/assets/javascripts/jquery.js +0 -2
- data/lib/assets/javascripts/mustache.js +0 -90
- data/lib/assets/javascripts/phantom.js +0 -63
- data/lib/assets/javascripts/qunit.js +0 -1510
- data/lib/assets/javascripts/release.js +0 -74
- data/lib/assets/javascripts/server.js +0 -14
- data/lib/assets/javascripts/spec.js +0 -77
- data/lib/assets/javascripts/template-1.0.5.js +0 -233
- data/lib/assets/javascripts/template.js +0 -233
- data/lib/assets/javascripts/web_templates.js +0 -32
- data/lib/assets/stylesheets/css-tests.css +0 -139
- data/lib/assets/stylesheets/docs.css +0 -1015
- data/lib/assets/stylesheets/layout.css +0 -206
- data/lib/assets/stylesheets/qunit.css +0 -232
- data/lib/assets/stylesheets/skeleton.css +0 -236
|
@@ -1,848 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2011 Twitter, Inc.
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
*
|
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
* See the License for the specific language governing permissions and
|
|
13
|
-
* limitations under the License.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
var Hogan = Hogan || require('../lib/hogan')
|
|
17
|
-
, doc = this["document"]
|
|
18
|
-
|
|
19
|
-
function testScanTextNoTags() {
|
|
20
|
-
var text = "<h2>hi</h2>";
|
|
21
|
-
var tokens = Hogan.scan(text);
|
|
22
|
-
is(tokens.length, 1, "One token");
|
|
23
|
-
is(tokens[0]+'', text, "text is equal to first token");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function testScanOneTag() {
|
|
27
|
-
var text = "{{hmm}}";
|
|
28
|
-
var tokens = Hogan.scan(text);
|
|
29
|
-
is(tokens.length, 1, "One token");
|
|
30
|
-
is(tokens[0].n, "hmm", "First token content is variable name.");
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function testScanMultipleTags() {
|
|
34
|
-
var text = "asdf{{hmm}}asdf2{{hmm2}}asdf3";
|
|
35
|
-
var tokens = Hogan.scan(text);
|
|
36
|
-
is(tokens.length, 5, "3 text tokens, 2 tag tokens.");
|
|
37
|
-
is(tokens[0]+'', "asdf", "first token is text");
|
|
38
|
-
is(tokens[1].n, "hmm", "second token is tag");
|
|
39
|
-
is(tokens[1].tag, "_v", "second token is a variable");
|
|
40
|
-
is(tokens[2]+'', "asdf2", "third token is text");
|
|
41
|
-
is(tokens[3].n, "hmm2", "fourth token is tag");
|
|
42
|
-
is(tokens[3].tag, "_v", "fourth token is a variable");
|
|
43
|
-
is(tokens[4]+'', "asdf3", "Fifth token is text");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function testScanSectionOpen() {
|
|
47
|
-
var text = "{{#hmm}}";
|
|
48
|
-
var tokens = Hogan.scan(text);
|
|
49
|
-
is(tokens.length, 1, "One token");
|
|
50
|
-
is(tokens[0].n, "hmm", "First token content is variable name.");
|
|
51
|
-
is(tokens[0].tag, "#", "First token is a section.");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function testScanSectionClose() {
|
|
55
|
-
var text = "{{/hmm}}";
|
|
56
|
-
var tokens = Hogan.scan(text);
|
|
57
|
-
is(tokens.length, 1, "One token");
|
|
58
|
-
is(tokens[0].n, "hmm", "First token content is variable name.");
|
|
59
|
-
is(tokens[0].tag, "/", "First token is a section.");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function testScanSection() {
|
|
63
|
-
var text = "{{#hmm}}{{/hmm}}";
|
|
64
|
-
var tokens = Hogan.scan(text);
|
|
65
|
-
is(tokens.length, 2, "One token");
|
|
66
|
-
is(tokens[0].n, "hmm", "First token content is variable name.");
|
|
67
|
-
is(tokens[0].tag, "#", "First token is a section.");
|
|
68
|
-
is(tokens[1].n, "hmm", "Second token content is variable name.");
|
|
69
|
-
is(tokens[1].tag, "/", "Second token is a section.");
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function testScanSectionInContent() {
|
|
73
|
-
var text = "abc{{#hmm}}def{{/hmm}}ghi";
|
|
74
|
-
var tokens = Hogan.scan(text);
|
|
75
|
-
is(tokens.length, 5, "3 text tokens, 2 tag tokens.");
|
|
76
|
-
is(tokens[0]+'', "abc", "first token is text");
|
|
77
|
-
is(tokens[1].n, "hmm", "second token is tag");
|
|
78
|
-
is(tokens[1].tag, "#", "second token is a variable");
|
|
79
|
-
is(tokens[2]+'', "def", "third token is text");
|
|
80
|
-
is(tokens[3].n, "hmm", "fourth token is tag");
|
|
81
|
-
is(tokens[3].tag, "/", "fourth token is a variable");
|
|
82
|
-
is(tokens[4]+'', "ghi", "Fifth token is text");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function testScanNegativeSection() {
|
|
86
|
-
var text = "{{^hmm}}{{/hmm}}";
|
|
87
|
-
var tokens = Hogan.scan(text);
|
|
88
|
-
is(tokens.length, 2, "One token");
|
|
89
|
-
is(tokens[0].n, "hmm", "First token content is variable name.");
|
|
90
|
-
is(tokens[0].tag, "^", "First token is a negative section.");
|
|
91
|
-
is(tokens[1].n, "hmm", "First token content is variable name.");
|
|
92
|
-
is(tokens[1].tag, "/", "Second token is a section.");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function testScanPartial() {
|
|
96
|
-
var text = "{{>hmm}}";
|
|
97
|
-
var tokens = Hogan.scan(text);
|
|
98
|
-
is(tokens.length, 1, "One token");
|
|
99
|
-
is(tokens[0].n, "hmm", "First token content is variable name.");
|
|
100
|
-
is(tokens[0].tag, ">", "First token is a partial.");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
function testScanBackwardPartial() {
|
|
105
|
-
var text = "{{<hmm}}";
|
|
106
|
-
var tokens = Hogan.scan(text);
|
|
107
|
-
is(tokens.length, 1, "One token");
|
|
108
|
-
is(tokens[0].n, "hmm", "First token content is variable name.");
|
|
109
|
-
is(tokens[0].tag, "<", "First token is a backward partial.");
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function testScanAmpersandNoEscapeTag() {
|
|
113
|
-
var text = "{{&hmm}}";
|
|
114
|
-
var tokens = Hogan.scan(text);
|
|
115
|
-
is(tokens.length, 1, "One token");
|
|
116
|
-
is(tokens[0].n, "hmm", "First token content is variable name.");
|
|
117
|
-
is(tokens[0].tag, "&", "First token is an ampersand no-escape.");
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function testScanTripleStache() {
|
|
121
|
-
var text = "{{{hmm}}}";
|
|
122
|
-
var tokens = Hogan.scan(text);
|
|
123
|
-
is(tokens.length, 1, "One token");
|
|
124
|
-
is(tokens[0].n, "hmm", "First token content is variable name.");
|
|
125
|
-
is(tokens[0].tag, "{", "First token is a triple-stache.");
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function testScanSectionWithTripleStacheInside() {
|
|
129
|
-
var text = "a{{#yo}}b{{{hmm}}}c{{/yo}}d";
|
|
130
|
-
var tokens = Hogan.scan(text);
|
|
131
|
-
is(tokens.length, 7, "One token");
|
|
132
|
-
is(tokens[0]+'', "a", "First token content is correct text.");
|
|
133
|
-
is(tokens[1].n, "yo", "Second token content is correct text.");
|
|
134
|
-
is(tokens[1].tag, "#", "Second token is a section.");
|
|
135
|
-
is(tokens[2]+'', "b", "Third token content is correct text.");
|
|
136
|
-
is(tokens[3].n, "hmm", "Fourth token content is correct text.");
|
|
137
|
-
is(tokens[3].tag, "{", "Fourth token is a triple stache.");
|
|
138
|
-
is(tokens[4]+'', "c", "Fifth token content is correct text.");
|
|
139
|
-
is(tokens[5].n, "yo", "Sixth token content is correct text.");
|
|
140
|
-
is(tokens[5].tag, "/", "Sixth token is a close.");
|
|
141
|
-
is(tokens[6]+'', "d", "Seventh token content is correct text.");
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function testScanSetDelimiter() {
|
|
145
|
-
var text = "a{{=<% %>=}}b";
|
|
146
|
-
var tokens = Hogan.scan(text);
|
|
147
|
-
is(tokens.length, 2, "change delimiter doesn't appear as token.");
|
|
148
|
-
is(tokens[0]+'', "a", "text before change delimiter is processed.");
|
|
149
|
-
is(tokens[1]+'', "b", "text after change delimiter is processed.");
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function testScanResetDelimiter() {
|
|
153
|
-
var text = "a{{=<% %>=}}b<%hmm%>c<%={{ }}=%>d{{hmm}}";
|
|
154
|
-
var tokens = Hogan.scan(text);
|
|
155
|
-
is(tokens.length, 6, "8 tokens, delimiter changes don't count.");
|
|
156
|
-
is(tokens[0]+'', "a", "first token is correct.");
|
|
157
|
-
is(tokens[1]+'', "b", "third token is correct.");
|
|
158
|
-
is(tokens[2].tag, "_v", "third token is correct tag.");
|
|
159
|
-
is(tokens[2].n, "hmm", "third token is correct name.");
|
|
160
|
-
is(tokens[3]+'', "c", "fifth token is correct.");
|
|
161
|
-
is(tokens[4]+'', "d", "seventh token is correct.");
|
|
162
|
-
is(tokens[5].tag, "_v", "eighth token is correct tag.");
|
|
163
|
-
is(tokens[5].n, "hmm", "eighth token is correct name.");
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function testSingleCharDelimiter() {
|
|
167
|
-
var text = '({{foo}} {{=[ ]=}}[text])';
|
|
168
|
-
var tokens = Hogan.scan(text);
|
|
169
|
-
|
|
170
|
-
var t = Hogan.compile(text);
|
|
171
|
-
s = t.render({foo: "bar", text: 'It worked!'});
|
|
172
|
-
is(s, '(bar It worked!)', "Hogan substitution worked after custom delimiters.");
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function testSetDelimiterWithWhitespace() {
|
|
176
|
-
var text = "{{= | | =}}|foo|";
|
|
177
|
-
var t = Hogan.compile(text);
|
|
178
|
-
s = t.render({foo: "bar"});
|
|
179
|
-
is(s, 'bar', "custom delimiters with whitespace works.")
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function testParseBasic() {
|
|
183
|
-
var text = "test";
|
|
184
|
-
var tree = Hogan.parse(Hogan.scan(text));
|
|
185
|
-
is(tree.length, 1, "one parse node");
|
|
186
|
-
is(tree[0]+'', "test", "text is correct");
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function testParseVariables() {
|
|
190
|
-
var text = "test{{foo}}test!{{bar}}test!!{{baz}}test!!!";
|
|
191
|
-
var tree = Hogan.parse(Hogan.scan(text));
|
|
192
|
-
is(tree.length, 7, "one parse node");
|
|
193
|
-
is(tree[0]+'', "test", "first text is correct");
|
|
194
|
-
is(tree[2]+'', "test!", "second text is correct")
|
|
195
|
-
is(tree[4]+'', "test!!", "third text is correct")
|
|
196
|
-
is(tree[6]+'', "test!!!", "last text is correct")
|
|
197
|
-
is(tree[1].n, "foo", "first var is correct");
|
|
198
|
-
is(tree[3].n, "bar", "second var is correct");
|
|
199
|
-
is(tree[5].n, "baz", "third var is correct");
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function testParseSection() {
|
|
203
|
-
var text = "a{{#foo}}b{{/foo}}c";
|
|
204
|
-
var tree = Hogan.parse(Hogan.scan(text));
|
|
205
|
-
is(tree.length, 3, "three nodes at base");
|
|
206
|
-
is(tree[0]+'', "a", "correct text in first node");
|
|
207
|
-
is(tree[1].hasOwnProperty('nodes'), true, "second node is a section");
|
|
208
|
-
is(tree[1].tag, '#', "second node is a section");
|
|
209
|
-
is(tree[1].n, "foo", "correct name for section");
|
|
210
|
-
is(tree[1].nodes[0]+'', "b", "correct text in section");
|
|
211
|
-
is(tree[2]+'', "c", "correct text in last node");
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function testParseIndexes() {
|
|
215
|
-
var text = "abc{{#foo}}asdf{{bar}}asdf{{/foo}}def";
|
|
216
|
-
var tree = Hogan.parse(Hogan.scan(text));
|
|
217
|
-
is(text.substring(tree[1].i, tree[1].end), "asdf{{bar}}asdf", "section text indexes are correct");
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function testParseNegativeSection() {
|
|
221
|
-
var text = "a{{^foo}}b{{/foo}}c";
|
|
222
|
-
var tree = Hogan.parse(Hogan.scan(text));
|
|
223
|
-
|
|
224
|
-
is(tree.length, 3, "three nodes at base");
|
|
225
|
-
is(tree[0]+'', "a", "correct text in first node");
|
|
226
|
-
is(tree[1].hasOwnProperty('nodes'), true, "second node is a section");
|
|
227
|
-
is(tree[1].tag, '^', "second node is a negative section");
|
|
228
|
-
is(tree[1].n, "foo", "correct name for section");
|
|
229
|
-
is(tree[1].nodes[0]+'', "b", "correct text in section");
|
|
230
|
-
is(tree[2]+'', "c", "correct text in last node");
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function testParseNestedSections() {
|
|
234
|
-
var text = "{{#bar}}{{#foo}}c{{/foo}}{{/bar}}"
|
|
235
|
-
var tree = Hogan.parse(Hogan.scan(text));
|
|
236
|
-
|
|
237
|
-
is(tree.length, 1, "one node at base");
|
|
238
|
-
is(tree[0].tag, "#", "open section is first node");
|
|
239
|
-
is(tree[0].n, "bar", "first section name is 'bar'");
|
|
240
|
-
is(tree[0].nodes.length, 1, "first section contains one node.");
|
|
241
|
-
is(tree[0].nodes[0].n, "foo", "correct name for nested section");
|
|
242
|
-
is(tree[0].nodes[0].nodes[0]+'', "c", "correct text in nested section");
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
function testMissingClosingTag() {
|
|
246
|
-
var text = "a{{#foo}}bc";
|
|
247
|
-
var msg = '';
|
|
248
|
-
try {
|
|
249
|
-
var tree = Hogan.parse(Hogan.scan(text));
|
|
250
|
-
} catch (e) {
|
|
251
|
-
msg = e.message;
|
|
252
|
-
}
|
|
253
|
-
is(msg, "missing closing tag: foo", "Error is generated");
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function testBadNesting() {
|
|
257
|
-
var text = "a{{#foo}}{{#bar}}b{{/foo}}{{/bar}}c";
|
|
258
|
-
var msg = '';
|
|
259
|
-
try {
|
|
260
|
-
var tree = Hogan.parse(Hogan.scan(text));
|
|
261
|
-
} catch (e) {
|
|
262
|
-
msg = e.message;
|
|
263
|
-
}
|
|
264
|
-
is(msg, "Nesting error: bar vs. foo", "Error is generated");
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function testBasicOutput() {
|
|
268
|
-
var text = "test";
|
|
269
|
-
var t = Hogan.compile(text);
|
|
270
|
-
is(t.render(), text, "template renders one text node");
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function testBasicOutputAsString() {
|
|
274
|
-
var text = "test";
|
|
275
|
-
var textFunc = Hogan.compile(text, true);
|
|
276
|
-
is(textFunc, "function(context, partials){this.buffer.push('test');};", "template renders correct text function.");
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function testOneVariable() {
|
|
280
|
-
var text = "test {{foo}} test";
|
|
281
|
-
var t = Hogan.compile(text);
|
|
282
|
-
var s = t.render({foo:'bar'});
|
|
283
|
-
is(s, "test bar test", "basic variable substitution works.");
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function testOneVariableAsString() {
|
|
287
|
-
var text = "test {{foo}} test";
|
|
288
|
-
var funcText = Hogan.compile(text, true);
|
|
289
|
-
is(funcText, "function(context, partials){this.buffer.push('test ');\nthis.buffer.push(this.find('foo', context));\nthis.buffer.push(' test');};",
|
|
290
|
-
"Function text is correct with variable substitution.");
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function testRenderWithWhitespace() {
|
|
294
|
-
var text = "{{ string }}";
|
|
295
|
-
var t = Hogan.compile(text);
|
|
296
|
-
is(t.render({string: "---" }), "---", "tags with whitespace render correctly.");
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function testRenderWithWhitespaceAroundTripleStache() {
|
|
300
|
-
var text = " {{{string}}}\n";
|
|
301
|
-
var t = Hogan.compile(text);
|
|
302
|
-
is(t.render({string: "---" }), " ---\n", "triple stache surrounded by whitespace render correctly.");
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function testRenderWithWhitespaceAroundAmpersand() {
|
|
306
|
-
var text = " {{& string }}\n";
|
|
307
|
-
var t = Hogan.compile(text);
|
|
308
|
-
is(t.render({string: "---" }), " ---\n", "ampersand surrounded by whitespace render correctly.");
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function testMultipleVariables() {
|
|
312
|
-
var text = "test {{foo}} test {{bar}} test {{baz}} test {{foo}} test";
|
|
313
|
-
var t = Hogan.compile(text);
|
|
314
|
-
var s = t.render({foo:'42', bar: '43', baz: '44'});
|
|
315
|
-
is(s, "test 42 test 43 test 44 test 42 test", "all variables render correctly.");
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
function testNumberValues() {
|
|
319
|
-
var text = "integer: {{foo}} float: {{bar}} negative: {{baz}}";
|
|
320
|
-
var t = Hogan.compile(text);
|
|
321
|
-
var s = t.render({foo: 42, bar: 42.42, baz: -42});
|
|
322
|
-
is(s, "integer: 42 float: 42.42 negative: -42", "numbers render correctly");
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
function testObjectRender() {
|
|
326
|
-
var text = "object: {{foo}}";
|
|
327
|
-
var t = Hogan.compile(text);
|
|
328
|
-
var s = t.render({foo: {}});
|
|
329
|
-
is(s, "object: [object Object]", "objects render default toString.");
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
function testObjectToStringRender() {
|
|
333
|
-
var text = "object: {{foo}}";
|
|
334
|
-
var t = Hogan.compile(text);
|
|
335
|
-
var s = t.render({foo: {toString: function(){ return "yo!"}}});
|
|
336
|
-
is(s, "object: yo!", "objects render supplied toString.");
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function testArrayRender() {
|
|
340
|
-
var text = "array: {{foo}}";
|
|
341
|
-
var t = Hogan.compile(text);
|
|
342
|
-
var s = t.render({foo: ["a","b","c"]});
|
|
343
|
-
is(s, "array: a,b,c", "arrays render default toString.");
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
function testEscaping() {
|
|
347
|
-
var text = "{{foo}}";
|
|
348
|
-
var t = Hogan.compile(text);
|
|
349
|
-
var s = t.render();
|
|
350
|
-
var s = t.render({foo: "< > <div> \' \" &"});
|
|
351
|
-
is(s, "< > <div> ' " &", "input correctly escaped.");
|
|
352
|
-
|
|
353
|
-
var ec ={ "'": "'", '"': """, "<": "<", ">": ">", "&": "&"}
|
|
354
|
-
for (var char in ec) {
|
|
355
|
-
var s = t.render({foo: char + " just me"});
|
|
356
|
-
is(s, ec[char] + " just me", "input correctly escaped.");
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
function testMustacheInjection() {
|
|
362
|
-
var text = "{{foo}}";
|
|
363
|
-
var t = Hogan.compile(text);
|
|
364
|
-
s = t.render({foo:"{{{<42}}}"})
|
|
365
|
-
is(s, "{{{<42}}}", "Can't inject mustache");
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function testTripleStache() {
|
|
369
|
-
var text = "{{{foo}}}";
|
|
370
|
-
var t = Hogan.compile(text);
|
|
371
|
-
var s = t.render({foo: "< > <div> \' \" &"});
|
|
372
|
-
is(s, "< > <div> \' \" &", "input correctly not-escaped.");
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
function testAmpNoEscaping() {
|
|
376
|
-
var text = "{{&foo}}";
|
|
377
|
-
var t = Hogan.compile(text);
|
|
378
|
-
var s = t.render({foo: "< > <div> \' \" &"});
|
|
379
|
-
is(s, "< > <div> \' \" &", "input correctly not-escaped.");
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
function testPartial() {
|
|
383
|
-
var partialText = "this is text from the partial--the magic number {{foo}} is from a variable";
|
|
384
|
-
var p = Hogan.compile(partialText);
|
|
385
|
-
|
|
386
|
-
var text = "This template contains a partial ({{>testPartial}})."
|
|
387
|
-
var t = Hogan.compile(text);
|
|
388
|
-
|
|
389
|
-
var s = t.render({foo: 42}, {testPartial: p});
|
|
390
|
-
is(s, "This template contains a partial (this is text from the partial--the magic number 42 is from a variable).", "partials work");
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
function testNestedPartials() {
|
|
394
|
-
var partialText = "this is text from the partial--the magic number {{foo}} is from a variable";
|
|
395
|
-
var p = Hogan.compile(partialText);
|
|
396
|
-
|
|
397
|
-
var partialText2 = "This template contains a partial ({{>testPartial}})."
|
|
398
|
-
var p2 = Hogan.compile(partialText2);
|
|
399
|
-
|
|
400
|
-
var text = "This template contains a partial that contains a partial [{{>testPartial2}}]."
|
|
401
|
-
var t = Hogan.compile(text);
|
|
402
|
-
|
|
403
|
-
var s = t.render({foo: 42}, {testPartial: p, testPartial2: p2});
|
|
404
|
-
is(s, "This template contains a partial that contains a partial [This template contains a partial (this is text from the partial--the magic number 42 is from a variable).].", "nested partials work");
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
function testNegativeSection() {
|
|
408
|
-
var text = "This template {{^foo}}BOO {{/foo}}contains an inverted section."
|
|
409
|
-
var t = Hogan.compile(text);
|
|
410
|
-
var s = t.render();
|
|
411
|
-
is(s, "This template BOO contains an inverted section.", "inverted sections with no context work");
|
|
412
|
-
|
|
413
|
-
s = t.render({foo:[]});
|
|
414
|
-
is(s, "This template BOO contains an inverted section.", "inverted sections with empty list context work");
|
|
415
|
-
|
|
416
|
-
s = t.render({ foo:false });
|
|
417
|
-
is(s, "This template BOO contains an inverted section.", "inverted sections with false context work");
|
|
418
|
-
|
|
419
|
-
s = t.render({foo:''});
|
|
420
|
-
is(s, "This template contains an inverted section.", "inverted sections with empty string context work");
|
|
421
|
-
|
|
422
|
-
s = t.render({foo:true});
|
|
423
|
-
is(s, "This template contains an inverted section.", "inverted sections with true context work");
|
|
424
|
-
|
|
425
|
-
s = t.render({foo: function() { return false; }});
|
|
426
|
-
is(s, "This template BOO contains an inverted section.", "inverted sections with false returning method in context work");
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
function testSectionElision() {
|
|
430
|
-
var text = "This template {{#foo}}BOO {{/foo}}contains a section."
|
|
431
|
-
var t = Hogan.compile(text);
|
|
432
|
-
var s = t.render();
|
|
433
|
-
is(s, "This template contains a section.", "sections with no context work");
|
|
434
|
-
|
|
435
|
-
s = t.render({foo:[]});
|
|
436
|
-
is(s, "This template contains a section.", "sections with empty list context work");
|
|
437
|
-
|
|
438
|
-
s = t.render({foo:false});
|
|
439
|
-
is(s, "This template contains a section.", "sections with false context work");
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
function testSectionObjectContext() {
|
|
443
|
-
var text = "This template {{#foo}}{{bar}} {{/foo}}contains a section."
|
|
444
|
-
var t = Hogan.compile(text);
|
|
445
|
-
var s = t.render({foo:{bar:42}});
|
|
446
|
-
is(s, "This template 42 contains a section.", "sections with object context work");
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
function testSectionArrayContext() {
|
|
450
|
-
var text = "This template {{#foo}}{{bar}} {{/foo}}contains a section."
|
|
451
|
-
var t = Hogan.compile(text);
|
|
452
|
-
var s = t.render({foo:[{bar:42}, {bar:43}, {bar:44}]});
|
|
453
|
-
is(s, "This template 42 43 44 contains a section.", "sections with object ctx and array values work");
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
function testFalsyVariableNoRender() {
|
|
457
|
-
var text = "I ({{cannot}}) be seen!";
|
|
458
|
-
var t = Hogan.compile(text);
|
|
459
|
-
var s = t.render();
|
|
460
|
-
is(s, "I () be seen!", "missing value doesn't render.");
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
function testSectionExtensions() {
|
|
464
|
-
var text = "Test {{_//|__foo}}bar{{/foo}}";
|
|
465
|
-
var options = {sectionTags:[{o:'_//|__foo', c:'foo'}]};
|
|
466
|
-
var tree = Hogan.parse(Hogan.scan(text), options);
|
|
467
|
-
is(tree[1].tag, "#", "_//|__foo node transformed to section");
|
|
468
|
-
is(tree[1].n, "_//|__foo", "_//|__foo node transformed to section");
|
|
469
|
-
|
|
470
|
-
var t = Hogan.compile(text, options );
|
|
471
|
-
var s = t.render({'_//|__foo':true});
|
|
472
|
-
is(s, "Test bar", "Custom sections work");
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
function testMisnestedSectionExtensions() {
|
|
476
|
-
var text = "Test {{__foo}}bar{{/bar}}";
|
|
477
|
-
var options = {sectionTags:[{o:'__foo', c:'foo'}, {o:'__bar', c:'bar'}]};
|
|
478
|
-
var msg = '';
|
|
479
|
-
try {
|
|
480
|
-
var tree = Hogan.parse(Hogan.scan(text), options);
|
|
481
|
-
} catch (e) {
|
|
482
|
-
msg = e.message;
|
|
483
|
-
}
|
|
484
|
-
is(msg, "Nesting error: __foo vs. bar", "Error is generated");
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
function testNestedSection() {
|
|
488
|
-
var text = "{{#foo}}{{#bar}}{{baz}}{{/bar}}{{/foo}}";
|
|
489
|
-
var t = Hogan.compile(text);
|
|
490
|
-
var s = t.render({foo: 42, bar: 42, baz:42});
|
|
491
|
-
is(s, "42", "can reach up context stack");
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
function testDottedNames() {
|
|
495
|
-
var text = '"{{person.name}}" == "{{#person}}{{name}}{{/person}}"';
|
|
496
|
-
var t = Hogan.compile(text);
|
|
497
|
-
var s = t.render({person:{name:'Joe'}});
|
|
498
|
-
is(s, '"Joe" == "Joe"', "dotted names work");
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
function testImplicitIterator() {
|
|
502
|
-
var text = '{{#stuff}} {{.}} {{/stuff}}';
|
|
503
|
-
var t = Hogan.compile(text);
|
|
504
|
-
var s = t.render({stuff:[42,43,44]});
|
|
505
|
-
is(s, " 42 43 44 ", "implicit iterators work");
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
function testPartialsAndDelimiters() {
|
|
509
|
-
var text = '{{>include}}*\n{{= | | =}}\n*|>include|';
|
|
510
|
-
var partialText = ' .{{value}}. ';
|
|
511
|
-
var partial = Hogan.compile(partialText);
|
|
512
|
-
var t = Hogan.compile(text);
|
|
513
|
-
var s = t.render({value:"yes"}, {'include':partial});
|
|
514
|
-
is(s, " .yes. *\n* .yes. ", "partials work around delimiters");
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
function testStringPartials() {
|
|
518
|
-
var text = "foo{{>mypartial}}baz";
|
|
519
|
-
var partialText = " bar ";
|
|
520
|
-
var t = Hogan.compile(text);
|
|
521
|
-
var s = t.render({}, {'mypartial': partialText});
|
|
522
|
-
is(s, "foo bar baz", "string partial works.");
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
function testMissingPartials() {
|
|
526
|
-
var text = "foo{{>mypartial}} bar";
|
|
527
|
-
var t = Hogan.compile(text);
|
|
528
|
-
var s = t.render({});
|
|
529
|
-
is(s, "foo bar", "missing partial works.");
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
function testIndentedStandaloneComment() {
|
|
533
|
-
var text = 'Begin.\n {{! Indented Comment Block! }}\nEnd.';
|
|
534
|
-
var t = Hogan.compile(text);
|
|
535
|
-
var s = t.render();
|
|
536
|
-
is(s, 'Begin.\nEnd.', "Standalone comment blocks are removed.");
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
function testNewLineBetweenDelimiterChanges() {
|
|
540
|
-
var data = { section: true, data: 'I got interpolated.' };
|
|
541
|
-
var text = '\n{{#section}}\n {{data}}\n |data|\n{{/section}}x\n\n{{= | | =}}\n|#section|\n {{data}}\n |data|\n|/section|';
|
|
542
|
-
var t = Hogan.compile(text);
|
|
543
|
-
var s = t.render(data);
|
|
544
|
-
is(s, '\n I got interpolated.\n |data|\nx\n\n {{data}}\n I got interpolated.\n', 'render correct')
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
function testMustacheJSApostrophe() {
|
|
548
|
-
var text = '{{apos}}{{control}}';
|
|
549
|
-
var t = Hogan.compile(text);
|
|
550
|
-
var s = t.render({'apos':"'", 'control':"X"});
|
|
551
|
-
is(s, ''X', 'Apostrophe is escaped.');
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
function testMustacheJSArrayOfImplicitPartials() {
|
|
555
|
-
var text = 'Here is some stuff!\n{{#numbers}}\n{{>partial}}\n{{/numbers}}\n';
|
|
556
|
-
var partialText = '{{.}}\n';
|
|
557
|
-
var t = Hogan.compile(text);
|
|
558
|
-
var s = t.render({numbers:[1,2,3,4]}, {partial: partialText});
|
|
559
|
-
is(s, 'Here is some stuff!\n1\n2\n3\n4\n', 'Partials with implicit iterators work.');
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
function testMustacheJSArrayOfPartials() {
|
|
563
|
-
var text = 'Here is some stuff!\n{{#numbers}}\n{{>partial}}\n{{/numbers}}\n';
|
|
564
|
-
var partialText = '{{i}}\n';
|
|
565
|
-
var t = Hogan.compile(text);
|
|
566
|
-
var s = t.render({numbers:[{i:1},{i:2},{i:3},{i:4}]}, {partial: partialText});
|
|
567
|
-
is(s, 'Here is some stuff!\n1\n2\n3\n4\n', 'Partials with arrays work.');
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
function testMustacheJSArrayOfStrings() {
|
|
571
|
-
var text = '{{#strings}}{{.}} {{/strings}}';
|
|
572
|
-
var t = Hogan.compile(text);
|
|
573
|
-
var s = t.render({strings:['foo', 'bar', 'baz']});
|
|
574
|
-
is(s, 'foo bar baz ', 'array of strings works with implicit iterators.');
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
function testMustacheJSUndefinedString() {
|
|
578
|
-
var text = 'foo{{bar}}baz';
|
|
579
|
-
var t = Hogan.compile(text);
|
|
580
|
-
var s = t.render({bar:undefined});
|
|
581
|
-
is(s, 'foobaz', 'undefined value does not render.');
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
function testMustacheJSTripleStacheAltDelimiter() {
|
|
585
|
-
var text = '{{=<% %>=}}<% foo %> {{foo}} <%{bar}%> {{{bar}}}';
|
|
586
|
-
var t = Hogan.compile(text);
|
|
587
|
-
var s = t.render({foo:'yeah', bar:'hmm'});
|
|
588
|
-
is(s, 'yeah {{foo}} hmm {{{bar}}}', 'triple stache inside alternate delimiter works.');
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
/* shootout benchmark tests */
|
|
592
|
-
|
|
593
|
-
function testShootOutString() {
|
|
594
|
-
var text = "Hello World!";
|
|
595
|
-
var expected = "Hello World!"
|
|
596
|
-
var t = Hogan.compile(text)
|
|
597
|
-
var s = t.render({})
|
|
598
|
-
is(s, expected, "Shootout String compiled correctly");
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
function testShootOutReplace() {
|
|
602
|
-
var text = "Hello {{name}}! You have {{count}} new messages.";
|
|
603
|
-
var expected = "Hello Mick! You have 30 new messages.";
|
|
604
|
-
var t = Hogan.compile(text)
|
|
605
|
-
var s = t.render({ name: "Mick", count: 30 })
|
|
606
|
-
is(s, expected, "Shootout Replace compiled correctly");
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
function testShootOutArray() {
|
|
610
|
-
var text = "{{#names}}{{name}}{{/names}}";
|
|
611
|
-
var expected = "MoeLarryCurlyShemp";
|
|
612
|
-
var t = Hogan.compile(text);
|
|
613
|
-
var s = t.render({ names: [{name: "Moe"}, {name: "Larry"}, {name: "Curly"}, {name: "Shemp"}] })
|
|
614
|
-
is(s, expected, "Shootout Array compiled correctly");
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
function testShootOutObject() {
|
|
618
|
-
var text = "{{#person}}{{name}}{{age}}{{/person}}";
|
|
619
|
-
var expected = "Larry45";
|
|
620
|
-
var t = Hogan.compile(text)
|
|
621
|
-
var s = t.render({ person: { name: "Larry", age: 45 } })
|
|
622
|
-
is(s, expected, "Shootout Object compiled correctly");
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
function testShootOutPartial() {
|
|
626
|
-
var text = "{{#peeps}}{{>replace}}{{/peeps}}";
|
|
627
|
-
var t = Hogan.compile(text);
|
|
628
|
-
var partial = Hogan.compile(" Hello {{name}}! You have {{count}} new messages.");
|
|
629
|
-
var s = t.render({ peeps: [{name: "Moe", count: 15}, {name: "Larry", count: 5}, {name: "Curly", count: 2}] }, { replace: partial });
|
|
630
|
-
var expected = " Hello Moe! You have 15 new messages. Hello Larry! You have 5 new messages. Hello Curly! You have 2 new messages.";
|
|
631
|
-
is(s, expected, "Shootout Partial compiled correctly");
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
function testShootOutRecurse() {
|
|
635
|
-
var text = "{{name}}{{#kids}}{{>recursion}}{{/kids}}";
|
|
636
|
-
var t = Hogan.compile(text);
|
|
637
|
-
var partial = Hogan.compile("{{name}}{{#kids}}{{>recursion}}{{/kids}}");
|
|
638
|
-
var s = t.render({
|
|
639
|
-
name: '1',
|
|
640
|
-
kids: [
|
|
641
|
-
{
|
|
642
|
-
name: '1.1',
|
|
643
|
-
kids: [
|
|
644
|
-
{ name: '1.1.1', kids: [] }
|
|
645
|
-
]
|
|
646
|
-
}
|
|
647
|
-
]
|
|
648
|
-
}, { recursion: partial });
|
|
649
|
-
var expected = "11.11.1.1";
|
|
650
|
-
is(s, expected, "Shootout Recurse compiled correctly");
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
function testShootOutFilter() {
|
|
654
|
-
var text = "{{#filter}}foo {{bar}}{{/filter}}";
|
|
655
|
-
var t = Hogan.compile(text);
|
|
656
|
-
var s = t.render({
|
|
657
|
-
filter: function() {
|
|
658
|
-
return function(text, render) {
|
|
659
|
-
return render(text).toUpperCase();
|
|
660
|
-
}
|
|
661
|
-
},
|
|
662
|
-
bar: "bar"
|
|
663
|
-
});
|
|
664
|
-
var expected = "FOO BAR"
|
|
665
|
-
is(s, expected, "Shootout Filter compiled correctly");
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
function testShootOutComplex() {
|
|
669
|
-
var text =
|
|
670
|
-
"<h1>{{header}}</h1>" +
|
|
671
|
-
"{{#hasItems}}" +
|
|
672
|
-
"<ul>" +
|
|
673
|
-
"{{#items}}" +
|
|
674
|
-
"{{#current}}" +
|
|
675
|
-
"<li><strong>{{name}}</strong></li>" +
|
|
676
|
-
"{{/current}}" +
|
|
677
|
-
"{{^current}}" +
|
|
678
|
-
"<li><a href=\"{{url}}\">{{name}}</a></li>" +
|
|
679
|
-
"{{/current}}" +
|
|
680
|
-
"{{/items}}" +
|
|
681
|
-
"</ul>" +
|
|
682
|
-
"{{/hasItems}}" +
|
|
683
|
-
"{{^hasItems}}" +
|
|
684
|
-
"<p>The list is empty.</p>" +
|
|
685
|
-
"{{/hasItems}}";
|
|
686
|
-
|
|
687
|
-
var expected = "<h1>Colors</h1><ul><li><strong>red</strong></li><li><a href=\"#Green\">green</a></li><li><a href=\"#Blue\">blue</a></li></ul>";
|
|
688
|
-
var t = Hogan.compile(text)
|
|
689
|
-
var s = t.render({
|
|
690
|
-
header: function() {
|
|
691
|
-
return "Colors";
|
|
692
|
-
},
|
|
693
|
-
items: [
|
|
694
|
-
{name: "red", current: true, url: "#Red"},
|
|
695
|
-
{name: "green", current: false, url: "#Green"},
|
|
696
|
-
{name: "blue", current: false, url: "#Blue"}
|
|
697
|
-
],
|
|
698
|
-
hasItems: function() {
|
|
699
|
-
return this.items.length !== 0;
|
|
700
|
-
},
|
|
701
|
-
empty: function() {
|
|
702
|
-
return this.items.length === 0;
|
|
703
|
-
}
|
|
704
|
-
})
|
|
705
|
-
|
|
706
|
-
is(s, expected, "Shootout Complex compiled correctly");
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
function testRenderOutput() {
|
|
710
|
-
if (doc) return
|
|
711
|
-
var fs = require('fs');
|
|
712
|
-
var inPath = 'test/templates';
|
|
713
|
-
var outPath = 'test/html';
|
|
714
|
-
|
|
715
|
-
fs.readdirSync(inPath).forEach(function (file) {
|
|
716
|
-
var i = fs.readFileSync([inPath, file].join('/'), 'utf-8');
|
|
717
|
-
var t = Hogan.compile(i);
|
|
718
|
-
var r = t.render({});
|
|
719
|
-
var o = fs.readFileSync([outPath, file].join('/').replace(/mustache$/, 'html')).toString();
|
|
720
|
-
is(r === o, true, file + ' should correctly render html')
|
|
721
|
-
})
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
function testDefaultRenderImpl() {
|
|
725
|
-
var ht = new Hogan.Template();
|
|
726
|
-
is(ht.render() === '', true, 'default renderImpl returns an array.');
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
function appendText(el, text) {
|
|
731
|
-
var textNode = document.createTextNode(text);
|
|
732
|
-
el.appendChild(textNode);
|
|
733
|
-
el.appendChild(document.createElement('br'));
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
if (!this["output"]) {
|
|
737
|
-
var output = function (s) {
|
|
738
|
-
return doc ? appendText(doc.getElementById('console'), s) : console.log(s);
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
var passed = 0;
|
|
742
|
-
var failed = 0;
|
|
743
|
-
|
|
744
|
-
function is(got, expected, msg) {
|
|
745
|
-
if (got === expected) {
|
|
746
|
-
output("OK: " + msg);
|
|
747
|
-
++passed;
|
|
748
|
-
} else {
|
|
749
|
-
output("FAIL: " + msg);
|
|
750
|
-
output("Expected |" + expected + "|");
|
|
751
|
-
output(" Got |" + got + "|");
|
|
752
|
-
++failed;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
function complete() {
|
|
757
|
-
output("\nTests Complete");
|
|
758
|
-
output("--------------");
|
|
759
|
-
output("Passed: " + passed);
|
|
760
|
-
output("Failed: " + failed);
|
|
761
|
-
output("\n");
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
function runTests() {
|
|
765
|
-
output("Tests Starting");
|
|
766
|
-
output("--------------");
|
|
767
|
-
testScanTextNoTags();
|
|
768
|
-
testScanOneTag();
|
|
769
|
-
testScanMultipleTags();
|
|
770
|
-
testScanSectionOpen();
|
|
771
|
-
testScanSectionClose();
|
|
772
|
-
testScanSection();
|
|
773
|
-
testScanSectionInContent();
|
|
774
|
-
testScanNegativeSection();
|
|
775
|
-
testScanPartial();
|
|
776
|
-
testScanBackwardPartial();
|
|
777
|
-
testScanAmpersandNoEscapeTag();
|
|
778
|
-
testScanTripleStache();
|
|
779
|
-
testScanSectionWithTripleStacheInside();
|
|
780
|
-
testScanSetDelimiter();
|
|
781
|
-
testScanResetDelimiter();
|
|
782
|
-
testSetDelimiterWithWhitespace();
|
|
783
|
-
testSingleCharDelimiter();
|
|
784
|
-
testParseBasic();
|
|
785
|
-
testParseVariables();
|
|
786
|
-
testParseSection();
|
|
787
|
-
testParseIndexes();
|
|
788
|
-
testParseNegativeSection();
|
|
789
|
-
testParseNestedSections();
|
|
790
|
-
testMissingClosingTag();
|
|
791
|
-
testBadNesting();
|
|
792
|
-
testBasicOutput();
|
|
793
|
-
//testBasicOutputAsString();
|
|
794
|
-
testOneVariable();
|
|
795
|
-
//testOneVariableAsString();
|
|
796
|
-
testMultipleVariables();
|
|
797
|
-
testNumberValues();
|
|
798
|
-
testObjectRender();
|
|
799
|
-
testObjectToStringRender();
|
|
800
|
-
testArrayRender();
|
|
801
|
-
testEscaping();
|
|
802
|
-
testMustacheInjection();
|
|
803
|
-
testTripleStache();
|
|
804
|
-
testAmpNoEscaping();
|
|
805
|
-
testPartial();
|
|
806
|
-
testNestedPartials();
|
|
807
|
-
testNegativeSection();
|
|
808
|
-
testSectionElision();
|
|
809
|
-
testSectionObjectContext();
|
|
810
|
-
testSectionArrayContext();
|
|
811
|
-
testRenderWithWhitespace();
|
|
812
|
-
testRenderWithWhitespaceAroundTripleStache();
|
|
813
|
-
testRenderWithWhitespaceAroundAmpersand();
|
|
814
|
-
testFalsyVariableNoRender();
|
|
815
|
-
testRenderOutput();
|
|
816
|
-
testDefaultRenderImpl();
|
|
817
|
-
testSectionExtensions();
|
|
818
|
-
testMisnestedSectionExtensions();
|
|
819
|
-
testNestedSection();
|
|
820
|
-
testShootOutString();
|
|
821
|
-
testShootOutReplace();
|
|
822
|
-
testShootOutArray();
|
|
823
|
-
testShootOutObject();
|
|
824
|
-
testShootOutPartial();
|
|
825
|
-
testShootOutRecurse();
|
|
826
|
-
testShootOutFilter();
|
|
827
|
-
testShootOutComplex();
|
|
828
|
-
testDottedNames();
|
|
829
|
-
testImplicitIterator();
|
|
830
|
-
testPartialsAndDelimiters();
|
|
831
|
-
testStringPartials();
|
|
832
|
-
testMissingPartials();
|
|
833
|
-
testIndentedStandaloneComment();
|
|
834
|
-
testNewLineBetweenDelimiterChanges();
|
|
835
|
-
testMustacheJSApostrophe();
|
|
836
|
-
testMustacheJSArrayOfImplicitPartials();
|
|
837
|
-
testMustacheJSArrayOfPartials();
|
|
838
|
-
testMustacheJSArrayOfStrings();
|
|
839
|
-
testMustacheJSUndefinedString();
|
|
840
|
-
testMustacheJSTripleStacheAltDelimiter();
|
|
841
|
-
complete();
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
if (doc) {
|
|
845
|
-
window.onload = runTests;
|
|
846
|
-
} else {
|
|
847
|
-
runTests();
|
|
848
|
-
}
|