corrade-nucleus-nucleons – Blame information for rev 20

Subversion Repositories:
Rev:
Rev Author Line No. Line
20 office 1 /*
2 AUTO-GENERATED. DO NOT MODIFY.
3 Script: test/generate-tests.js
4 Template: test/data/html/node.mustache
5 Data: test/data/html/tests.js
6  
7 The MIT License (MIT)
8  
9 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors.
10  
11 Permission is hereby granted, free of charge, to any person
12 obtaining a copy of this software and associated documentation files
13 (the "Software"), to deal in the Software without restriction,
14 including without limitation the rights to use, copy, modify, merge,
15 publish, distribute, sublicense, and/or sell copies of the Software,
16 and to permit persons to whom the Software is furnished to do so,
17 subject to the following conditions:
18  
19 The above copyright notice and this permission notice shall be
20 included in all copies or substantial portions of the Software.
21  
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
26 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
28 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 SOFTWARE.
30 */
31 /*jshint unused:false */
32  
33 function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_beautify)
34 {
35  
36 var default_opts = {
37 indent_size: 4,
38 indent_char: ' ',
39 preserve_newlines: true,
40 jslint_happy: false,
41 keep_array_indentation: false,
42 brace_style: 'collapse',
43 space_before_conditional: true,
44 break_chained_methods: false,
45 selector_separator: '\n',
46 end_with_newline: false
47 };
48 var opts;
49  
50 default_opts.indent_size = 4;
51 default_opts.indent_char = ' ';
52 default_opts.indent_with_tabs = false;
53 default_opts.preserve_newlines = true;
54 default_opts.jslint_happy = false;
55 default_opts.keep_array_indentation = false;
56 default_opts.brace_style = 'collapse';
57 default_opts.extra_liners = ['html', 'head', '/html'];
58  
59 function reset_options()
60 {
61 opts = JSON.parse(JSON.stringify(default_opts));
62 }
63  
64 function test_html_beautifier(input)
65 {
66 return html_beautify(input, opts);
67 }
68  
69 var sanitytest;
70  
71 // test the input on beautifier with the current flag settings
72 // does not check the indentation / surroundings as bt() does
73 function test_fragment(input, expected)
74 {
75 expected = expected || expected === '' ? expected : input;
76 sanitytest.expect(input, expected);
77 // if the expected is different from input, run it again
78 // expected output should be unchanged when run twice.
79 if (expected !== input) {
80 sanitytest.expect(expected, expected);
81 }
82  
83 // Everywhere we do newlines, they should be replaced with opts.eol
84 opts.eol = '\r\n';
85 expected = expected.replace(/[\n]/g, '\r\n');
86 sanitytest.expect(input, expected);
87 if (input.indexOf('\n') !== -1) {
88 input = input.replace(/[\n]/g, '\r\n');
89 sanitytest.expect(input, expected);
90 // Ensure support for auto eol detection
91 opts.eol = 'auto';
92 sanitytest.expect(input, expected);
93 }
94 opts.eol = '\n';
95 }
96  
97 // test html
98 function bth(input, expectation)
99 {
100 var wrapped_input, wrapped_expectation, field_input, field_expectation;
101  
102 expectation = expectation || expectation === '' ? expectation : input;
103 sanitytest.test_function(test_html_beautifier, 'html_beautify');
104 test_fragment(input, expectation);
105  
106 if (opts.indent_size === 4 && input) {
107 wrapped_input = '<div>\n' + input.replace(/^(.+)$/mg, ' $1') + '\n <span>inline</span>\n</div>';
108 wrapped_expectation = '<div>\n' + expectation.replace(/^(.+)$/mg, ' $1') + '\n <span>inline</span>\n</div>';
109 test_fragment(wrapped_input, wrapped_expectation);
110 }
111 }
112  
113 function unicode_char(value) {
114 return String.fromCharCode(value);
115 }
116  
117 function beautifier_tests()
118 {
119 sanitytest = test_obj;
120  
121 reset_options();
122 //============================================================
123 bth('');
124  
125  
126 //============================================================
127 // Handle inline and block elements differently - ()
128 reset_options();
129 test_fragment(
130 '<body><h1>Block</h1></body>',
131 // -- output --
132 '<body>\n' +
133 ' <h1>Block</h1>\n' +
134 '</body>');
135 test_fragment('<body><i>Inline</i></body>');
136  
137  
138 //============================================================
139 // End With Newline - (eof = "\n")
140 reset_options();
141 opts.end_with_newline = true;
142 test_fragment('', '\n');
143 test_fragment('<div></div>', '<div></div>\n');
144 test_fragment('\n');
145  
146 // End With Newline - (eof = "")
147 reset_options();
148 opts.end_with_newline = false;
149 test_fragment('');
150 test_fragment('<div></div>');
151 test_fragment('\n', '');
152  
153  
154 //============================================================
155 // Custom Extra Liners (empty) - ()
156 reset_options();
157 opts.extra_liners = [];
158 test_fragment(
159 '<html><head><meta></head><body><div><p>x</p></div></body></html>',
160 // -- output --
161 '<html>\n' +
162 '<head>\n' +
163 ' <meta>\n' +
164 '</head>\n' +
165 '<body>\n' +
166 ' <div>\n' +
167 ' <p>x</p>\n' +
168 ' </div>\n' +
169 '</body>\n' +
170 '</html>');
171  
172  
173 //============================================================
174 // Custom Extra Liners (default) - ()
175 reset_options();
176 opts.extra_liners = null;
177 test_fragment(
178 '<html><head></head><body></body></html>',
179 // -- output --
180 '<html>\n' +
181 '\n' +
182 '<head></head>\n' +
183 '\n' +
184 '<body></body>\n' +
185 '\n' +
186 '</html>');
187  
188  
189 //============================================================
190 // Custom Extra Liners (p, string) - ()
191 reset_options();
192 opts.extra_liners = 'p,/p';
193 test_fragment(
194 '<html><head><meta></head><body><div><p>x</p></div></body></html>',
195 // -- output --
196 '<html>\n' +
197 '<head>\n' +
198 ' <meta>\n' +
199 '</head>\n' +
200 '<body>\n' +
201 ' <div>\n' +
202 '\n' +
203 ' <p>x\n' +
204 '\n' +
205 ' </p>\n' +
206 ' </div>\n' +
207 '</body>\n' +
208 '</html>');
209  
210  
211 //============================================================
212 // Custom Extra Liners (p) - ()
213 reset_options();
214 opts.extra_liners = ['p', '/p'];
215 test_fragment(
216 '<html><head><meta></head><body><div><p>x</p></div></body></html>',
217 // -- output --
218 '<html>\n' +
219 '<head>\n' +
220 ' <meta>\n' +
221 '</head>\n' +
222 '<body>\n' +
223 ' <div>\n' +
224 '\n' +
225 ' <p>x\n' +
226 '\n' +
227 ' </p>\n' +
228 ' </div>\n' +
229 '</body>\n' +
230 '</html>');
231  
232  
233 //============================================================
234 // Tests for script and style types (issue 453, 821)
235 reset_options();
236 bth(
237 '<script type="text/unknown"><div></div></script>',
238 // -- output --
239 '<script type="text/unknown">\n' +
240 ' <div></div>\n' +
241 '</script>');
242 bth(
243 '<script type="text/javascript"><div></div></script>',
244 // -- output --
245 '<script type="text/javascript">\n' +
246 ' < div > < /div>\n' +
247 '</script>');
248 bth(
249 '<script><div></div></script>',
250 // -- output --
251 '<script>\n' +
252 ' < div > < /div>\n' +
253 '</script>');
254 bth(
255 '<script>var foo = "bar";</script>',
256 // -- output --
257 '<script>\n' +
258 ' var foo = "bar";\n' +
259 '</script>');
260 bth(
261 '<script type="text/javascript">var foo = "bar";</script>',
262 // -- output --
263 '<script type="text/javascript">\n' +
264 ' var foo = "bar";\n' +
265 '</script>');
266 bth(
267 '<script type="application/javascript">var foo = "bar";</script>',
268 // -- output --
269 '<script type="application/javascript">\n' +
270 ' var foo = "bar";\n' +
271 '</script>');
272 bth(
273 '<script type="application/javascript;version=1.8">var foo = "bar";</script>',
274 // -- output --
275 '<script type="application/javascript;version=1.8">\n' +
276 ' var foo = "bar";\n' +
277 '</script>');
278 bth(
279 '<script type="application/x-javascript">var foo = "bar";</script>',
280 // -- output --
281 '<script type="application/x-javascript">\n' +
282 ' var foo = "bar";\n' +
283 '</script>');
284 bth(
285 '<script type="application/ecmascript">var foo = "bar";</script>',
286 // -- output --
287 '<script type="application/ecmascript">\n' +
288 ' var foo = "bar";\n' +
289 '</script>');
290 bth(
291 '<script type="dojo/aspect">this.domNode.style.display="none";</script>',
292 // -- output --
293 '<script type="dojo/aspect">\n' +
294 ' this.domNode.style.display = "none";\n' +
295 '</script>');
296 bth(
297 '<script type="dojo/method">this.domNode.style.display="none";</script>',
298 // -- output --
299 '<script type="dojo/method">\n' +
300 ' this.domNode.style.display = "none";\n' +
301 '</script>');
302 bth(
303 '<script type="text/javascript1.5">var foo = "bar";</script>',
304 // -- output --
305 '<script type="text/javascript1.5">\n' +
306 ' var foo = "bar";\n' +
307 '</script>');
308 bth(
309 '<script type="application/json">{"foo":"bar"}</script>',
310 // -- output --
311 '<script type="application/json">\n' +
312 ' {\n' +
313 ' "foo": "bar"\n' +
314 ' }\n' +
315 '</script>');
316 bth(
317 '<script type="application/ld+json">{"foo":"bar"}</script>',
318 // -- output --
319 '<script type="application/ld+json">\n' +
320 ' {\n' +
321 ' "foo": "bar"\n' +
322 ' }\n' +
323 '</script>');
324 bth(
325 '<style type="text/unknown"><tag></tag></style>',
326 // -- output --
327 '<style type="text/unknown">\n' +
328 ' <tag></tag>\n' +
329 '</style>');
330 bth(
331 '<style type="text/css"><tag></tag></style>',
332 // -- output --
333 '<style type="text/css">\n' +
334 ' <tag></tag>\n' +
335 '</style>');
336 bth(
337 '<style><tag></tag></style>',
338 // -- output --
339 '<style>\n' +
340 ' <tag></tag>\n' +
341 '</style>');
342 bth(
343 '<style>.selector {font-size:12px;}</style>',
344 // -- output --
345 '<style>\n' +
346 ' .selector {\n' +
347 ' font-size: 12px;\n' +
348 ' }\n' +
349 '</style>');
350 bth(
351 '<style type="text/css">.selector {font-size:12px;}</style>',
352 // -- output --
353 '<style type="text/css">\n' +
354 ' .selector {\n' +
355 ' font-size: 12px;\n' +
356 ' }\n' +
357 '</style>');
358  
359  
360 //============================================================
361 // Attribute Wrap alignment with spaces - ()
362 reset_options();
363 opts.wrap_attributes = 'force-aligned';
364 opts.indent_with_tabs = true;
365 test_fragment(
366 '<div><div a="1" b="2"><div>test</div></div></div>',
367 // -- output --
368 '<div>\n' +
369 '\t<div a="1"\n' +
370 '\t b="2">\n' +
371 '\t\t<div>test</div>\n' +
372 '\t</div>\n' +
373 '</div>');
374  
375  
376 //============================================================
377 // Attribute Wrap de-indent - ()
378 reset_options();
379 opts.wrap_attributes = 'force-aligned';
380 opts.indent_with_tabs = false;
381 test_fragment(
382 '<div a="1" b="2"><div>test</div></div>',
383 // -- output --
384 '<div a="1"\n' +
385 ' b="2">\n' +
386 ' <div>test</div>\n' +
387 '</div>');
388 test_fragment(
389 '<p>\n' +
390 ' <a href="/test/" target="_blank"><img src="test.jpg" /></a><a href="/test/" target="_blank"><img src="test.jpg" /></a>\n' +
391 '</p>',
392 // -- output --
393 '<p>\n' +
394 ' <a href="/test/"\n' +
395 ' target="_blank"><img src="test.jpg" /></a><a href="/test/"\n' +
396 ' target="_blank"><img src="test.jpg" /></a>\n' +
397 '</p>');
398 test_fragment(
399 '<p>\n' +
400 ' <span data-not-a-href="/test/" data-totally-not-a-target="_blank"><img src="test.jpg" /></span><span data-not-a-href="/test/" data-totally-not-a-target="_blank"><img src="test.jpg" /></span>\n' +
401 '</p>',
402 // -- output --
403 '<p>\n' +
404 ' <span data-not-a-href="/test/"\n' +
405 ' data-totally-not-a-target="_blank"><img src="test.jpg" /></span><span data-not-a-href="/test/"\n' +
406 ' data-totally-not-a-target="_blank"><img src="test.jpg" /></span>\n' +
407 '</p>');
408  
409  
410 //============================================================
411 // Attribute Wrap - (indent_attr = "\n ", indent_attr_first = " ", indent_end = "", indent_end_selfclosing = " ", indent_over80 = "\n ")
412 reset_options();
413 opts.wrap_attributes = 'force';
414 test_fragment('<div >This is some text</div>', '<div>This is some text</div>');
415 test_fragment('<div attr="123" >This is some text</div>', '<div attr="123">This is some text</div>');
416 test_fragment(
417 '<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>',
418 // -- output --
419 '<div attr0\n' +
420 ' attr1="123"\n' +
421 ' data-attr2="hello t here">This is some text</div>');
422 test_fragment(
423 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>',
424 // -- output --
425 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true"\n' +
426 ' attr0\n' +
427 ' attr1="123"\n' +
428 ' data-attr2="hello t here"\n' +
429 ' heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>');
430 test_fragment(
431 '<img attr0 attr1="123" data-attr2="hello t here"/>',
432 // -- output --
433 '<img attr0\n' +
434 ' attr1="123"\n' +
435 ' data-attr2="hello t here" />');
436 test_fragment(
437 '<?xml version="1.0" encoding="UTF-8" ?><root attr1="foo" attr2="bar"/>',
438 // -- output --
439 '<?xml version="1.0" encoding="UTF-8" ?>\n' +
440 '<root attr1="foo"\n' +
441 ' attr2="bar" />');
442 test_fragment(
443 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin" rel="stylesheet" type="text/css">',
444 // -- output --
445 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin"\n' +
446 ' rel="stylesheet"\n' +
447 ' type="text/css">');
448  
449 // Attribute Wrap - (indent_attr = "\n ", indent_attr_first = " ", indent_end = "", indent_end_selfclosing = " ", indent_over80 = "\n ")
450 reset_options();
451 opts.wrap_attributes = 'force';
452 opts.wrap_line_length = 80;
453 test_fragment('<div >This is some text</div>', '<div>This is some text</div>');
454 test_fragment('<div attr="123" >This is some text</div>', '<div attr="123">This is some text</div>');
455 test_fragment(
456 '<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>',
457 // -- output --
458 '<div attr0\n' +
459 ' attr1="123"\n' +
460 ' data-attr2="hello t here">This is some text</div>');
461 test_fragment(
462 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>',
463 // -- output --
464 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true"\n' +
465 ' attr0\n' +
466 ' attr1="123"\n' +
467 ' data-attr2="hello t here"\n' +
468 ' heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>');
469 test_fragment(
470 '<img attr0 attr1="123" data-attr2="hello t here"/>',
471 // -- output --
472 '<img attr0\n' +
473 ' attr1="123"\n' +
474 ' data-attr2="hello t here" />');
475 test_fragment(
476 '<?xml version="1.0" encoding="UTF-8" ?><root attr1="foo" attr2="bar"/>',
477 // -- output --
478 '<?xml version="1.0" encoding="UTF-8" ?>\n' +
479 '<root attr1="foo"\n' +
480 ' attr2="bar" />');
481 test_fragment(
482 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin" rel="stylesheet" type="text/css">',
483 // -- output --
484 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin"\n' +
485 ' rel="stylesheet"\n' +
486 ' type="text/css">');
487  
488 // Attribute Wrap - (indent_attr = "\n ", indent_attr_first = " ", indent_end = "", indent_end_selfclosing = " ", indent_over80 = "\n ")
489 reset_options();
490 opts.wrap_attributes = 'force';
491 opts.wrap_attributes_indent_size = 8;
492 test_fragment('<div >This is some text</div>', '<div>This is some text</div>');
493 test_fragment('<div attr="123" >This is some text</div>', '<div attr="123">This is some text</div>');
494 test_fragment(
495 '<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>',
496 // -- output --
497 '<div attr0\n' +
498 ' attr1="123"\n' +
499 ' data-attr2="hello t here">This is some text</div>');
500 test_fragment(
501 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>',
502 // -- output --
503 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true"\n' +
504 ' attr0\n' +
505 ' attr1="123"\n' +
506 ' data-attr2="hello t here"\n' +
507 ' heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>');
508 test_fragment(
509 '<img attr0 attr1="123" data-attr2="hello t here"/>',
510 // -- output --
511 '<img attr0\n' +
512 ' attr1="123"\n' +
513 ' data-attr2="hello t here" />');
514 test_fragment(
515 '<?xml version="1.0" encoding="UTF-8" ?><root attr1="foo" attr2="bar"/>',
516 // -- output --
517 '<?xml version="1.0" encoding="UTF-8" ?>\n' +
518 '<root attr1="foo"\n' +
519 ' attr2="bar" />');
520 test_fragment(
521 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin" rel="stylesheet" type="text/css">',
522 // -- output --
523 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin"\n' +
524 ' rel="stylesheet"\n' +
525 ' type="text/css">');
526  
527 // Attribute Wrap - (indent_attr = " ", indent_attr_first = " ", indent_end = "", indent_end_selfclosing = " ", indent_over80 = "\n")
528 reset_options();
529 opts.wrap_attributes = 'auto';
530 opts.wrap_line_length = 80;
531 opts.wrap_attributes_indent_size = 0;
532 test_fragment('<div >This is some text</div>', '<div>This is some text</div>');
533 test_fragment('<div attr="123" >This is some text</div>', '<div attr="123">This is some text</div>');
534 test_fragment('<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>');
535 test_fragment(
536 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>',
537 // -- output --
538 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here"\n' +
539 'heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>');
540 test_fragment('<img attr0 attr1="123" data-attr2="hello t here"/>', '<img attr0 attr1="123" data-attr2="hello t here" />');
541 test_fragment(
542 '<?xml version="1.0" encoding="UTF-8" ?><root attr1="foo" attr2="bar"/>',
543 // -- output --
544 '<?xml version="1.0" encoding="UTF-8" ?>\n' +
545 '<root attr1="foo" attr2="bar" />');
546 test_fragment(
547 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin" rel="stylesheet" type="text/css">',
548 // -- output --
549 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin"\n' +
550 'rel="stylesheet" type="text/css">');
551  
552 // Attribute Wrap - (indent_attr = " ", indent_attr_first = " ", indent_end = "", indent_end_selfclosing = " ", indent_over80 = "\n ")
553 reset_options();
554 opts.wrap_attributes = 'auto';
555 opts.wrap_line_length = 80;
556 opts.wrap_attributes_indent_size = 4;
557 test_fragment('<div >This is some text</div>', '<div>This is some text</div>');
558 test_fragment('<div attr="123" >This is some text</div>', '<div attr="123">This is some text</div>');
559 test_fragment('<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>');
560 test_fragment(
561 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>',
562 // -- output --
563 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here"\n' +
564 ' heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>');
565 test_fragment('<img attr0 attr1="123" data-attr2="hello t here"/>', '<img attr0 attr1="123" data-attr2="hello t here" />');
566 test_fragment(
567 '<?xml version="1.0" encoding="UTF-8" ?><root attr1="foo" attr2="bar"/>',
568 // -- output --
569 '<?xml version="1.0" encoding="UTF-8" ?>\n' +
570 '<root attr1="foo" attr2="bar" />');
571 test_fragment(
572 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin" rel="stylesheet" type="text/css">',
573 // -- output --
574 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin"\n' +
575 ' rel="stylesheet" type="text/css">');
576  
577 // Attribute Wrap - (indent_attr = " ", indent_attr_first = " ", indent_end = "", indent_end_selfclosing = " ", indent_over80 = " ")
578 reset_options();
579 opts.wrap_attributes = 'auto';
580 opts.wrap_line_length = 0;
581 test_fragment('<div >This is some text</div>', '<div>This is some text</div>');
582 test_fragment('<div attr="123" >This is some text</div>', '<div attr="123">This is some text</div>');
583 test_fragment('<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>');
584 test_fragment('<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>');
585 test_fragment('<img attr0 attr1="123" data-attr2="hello t here"/>', '<img attr0 attr1="123" data-attr2="hello t here" />');
586 test_fragment(
587 '<?xml version="1.0" encoding="UTF-8" ?><root attr1="foo" attr2="bar"/>',
588 // -- output --
589 '<?xml version="1.0" encoding="UTF-8" ?>\n' +
590 '<root attr1="foo" attr2="bar" />');
591 test_fragment('<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin" rel="stylesheet" type="text/css">');
592  
593 // Attribute Wrap - (indent_attr = "\n ", indent_attr_faligned = " ", indent_attr_first = " ", indent_end = "", indent_end_selfclosing = " ", indent_over80 = "\n ")
594 reset_options();
595 opts.wrap_attributes = 'force-aligned';
596 test_fragment('<div >This is some text</div>', '<div>This is some text</div>');
597 test_fragment('<div attr="123" >This is some text</div>', '<div attr="123">This is some text</div>');
598 test_fragment(
599 '<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>',
600 // -- output --
601 '<div attr0\n' +
602 ' attr1="123"\n' +
603 ' data-attr2="hello t here">This is some text</div>');
604 test_fragment(
605 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>',
606 // -- output --
607 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true"\n' +
608 ' attr0\n' +
609 ' attr1="123"\n' +
610 ' data-attr2="hello t here"\n' +
611 ' heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>');
612 test_fragment(
613 '<img attr0 attr1="123" data-attr2="hello t here"/>',
614 // -- output --
615 '<img attr0\n' +
616 ' attr1="123"\n' +
617 ' data-attr2="hello t here" />');
618 test_fragment(
619 '<?xml version="1.0" encoding="UTF-8" ?><root attr1="foo" attr2="bar"/>',
620 // -- output --
621 '<?xml version="1.0" encoding="UTF-8" ?>\n' +
622 '<root attr1="foo"\n' +
623 ' attr2="bar" />');
624 test_fragment(
625 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin" rel="stylesheet" type="text/css">',
626 // -- output --
627 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin"\n' +
628 ' rel="stylesheet"\n' +
629 ' type="text/css">');
630  
631 // Attribute Wrap - (indent_attr = "\n ", indent_attr_faligned = " ", indent_attr_first = " ", indent_end = "", indent_end_selfclosing = " ", indent_over80 = "\n ")
632 reset_options();
633 opts.wrap_attributes = 'force-aligned';
634 opts.wrap_line_length = 80;
635 test_fragment('<div >This is some text</div>', '<div>This is some text</div>');
636 test_fragment('<div attr="123" >This is some text</div>', '<div attr="123">This is some text</div>');
637 test_fragment(
638 '<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>',
639 // -- output --
640 '<div attr0\n' +
641 ' attr1="123"\n' +
642 ' data-attr2="hello t here">This is some text</div>');
643 test_fragment(
644 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>',
645 // -- output --
646 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true"\n' +
647 ' attr0\n' +
648 ' attr1="123"\n' +
649 ' data-attr2="hello t here"\n' +
650 ' heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>');
651 test_fragment(
652 '<img attr0 attr1="123" data-attr2="hello t here"/>',
653 // -- output --
654 '<img attr0\n' +
655 ' attr1="123"\n' +
656 ' data-attr2="hello t here" />');
657 test_fragment(
658 '<?xml version="1.0" encoding="UTF-8" ?><root attr1="foo" attr2="bar"/>',
659 // -- output --
660 '<?xml version="1.0" encoding="UTF-8" ?>\n' +
661 '<root attr1="foo"\n' +
662 ' attr2="bar" />');
663 test_fragment(
664 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin" rel="stylesheet" type="text/css">',
665 // -- output --
666 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin"\n' +
667 ' rel="stylesheet"\n' +
668 ' type="text/css">');
669  
670 // Attribute Wrap - (indent_attr = "\n ", indent_attr_faligned = " ", indent_attr_first = " ", indent_end = "", indent_end_selfclosing = " ", indent_over80 = "\n ")
671 reset_options();
672 opts.wrap_attributes = 'force-aligned';
673 opts.wrap_attributes_indent_size = 8;
674 test_fragment('<div >This is some text</div>', '<div>This is some text</div>');
675 test_fragment('<div attr="123" >This is some text</div>', '<div attr="123">This is some text</div>');
676 test_fragment(
677 '<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>',
678 // -- output --
679 '<div attr0\n' +
680 ' attr1="123"\n' +
681 ' data-attr2="hello t here">This is some text</div>');
682 test_fragment(
683 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>',
684 // -- output --
685 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true"\n' +
686 ' attr0\n' +
687 ' attr1="123"\n' +
688 ' data-attr2="hello t here"\n' +
689 ' heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>');
690 test_fragment(
691 '<img attr0 attr1="123" data-attr2="hello t here"/>',
692 // -- output --
693 '<img attr0\n' +
694 ' attr1="123"\n' +
695 ' data-attr2="hello t here" />');
696 test_fragment(
697 '<?xml version="1.0" encoding="UTF-8" ?><root attr1="foo" attr2="bar"/>',
698 // -- output --
699 '<?xml version="1.0" encoding="UTF-8" ?>\n' +
700 '<root attr1="foo"\n' +
701 ' attr2="bar" />');
702 test_fragment(
703 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin" rel="stylesheet" type="text/css">',
704 // -- output --
705 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin"\n' +
706 ' rel="stylesheet"\n' +
707 ' type="text/css">');
708  
709 // Attribute Wrap - (indent_attr = "\n ", indent_attr_first = "\n ", indent_end = "\n", indent_end_selfclosing = "\n", indent_over80 = "\n ")
710 reset_options();
711 opts.wrap_attributes = 'force-expand-multiline';
712 opts.wrap_attributes_indent_size = 4;
713 test_fragment('<div >This is some text</div>', '<div>This is some text</div>');
714 test_fragment('<div attr="123" >This is some text</div>', '<div attr="123">This is some text</div>');
715 test_fragment(
716 '<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>',
717 // -- output --
718 '<div\n' +
719 ' attr0\n' +
720 ' attr1="123"\n' +
721 ' data-attr2="hello t here"\n' +
722 '>This is some text</div>');
723 test_fragment(
724 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>',
725 // -- output --
726 '<div\n' +
727 ' lookatthissuperduperlongattributenamewhoahcrazy0="true"\n' +
728 ' attr0\n' +
729 ' attr1="123"\n' +
730 ' data-attr2="hello t here"\n' +
731 ' heymanimreallylongtoowhocomesupwiththesenames="false"\n' +
732 '>This is some text</div>');
733 test_fragment(
734 '<img attr0 attr1="123" data-attr2="hello t here"/>',
735 // -- output --
736 '<img\n' +
737 ' attr0\n' +
738 ' attr1="123"\n' +
739 ' data-attr2="hello t here"\n' +
740 '/>');
741 test_fragment(
742 '<?xml version="1.0" encoding="UTF-8" ?><root attr1="foo" attr2="bar"/>',
743 // -- output --
744 '<?xml version="1.0" encoding="UTF-8" ?>\n' +
745 '<root\n' +
746 ' attr1="foo"\n' +
747 ' attr2="bar"\n' +
748 '/>');
749 test_fragment(
750 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin" rel="stylesheet" type="text/css">',
751 // -- output --
752 '<link\n' +
753 ' href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin"\n' +
754 ' rel="stylesheet"\n' +
755 ' type="text/css"\n' +
756 '>');
757  
758 // Attribute Wrap - (indent_attr = "\n ", indent_attr_first = "\n ", indent_end = "\n", indent_end_selfclosing = "\n", indent_over80 = "\n ")
759 reset_options();
760 opts.wrap_attributes = 'force-expand-multiline';
761 opts.wrap_attributes_indent_size = 4;
762 opts.wrap_line_length = 80;
763 test_fragment('<div >This is some text</div>', '<div>This is some text</div>');
764 test_fragment('<div attr="123" >This is some text</div>', '<div attr="123">This is some text</div>');
765 test_fragment(
766 '<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>',
767 // -- output --
768 '<div\n' +
769 ' attr0\n' +
770 ' attr1="123"\n' +
771 ' data-attr2="hello t here"\n' +
772 '>This is some text</div>');
773 test_fragment(
774 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>',
775 // -- output --
776 '<div\n' +
777 ' lookatthissuperduperlongattributenamewhoahcrazy0="true"\n' +
778 ' attr0\n' +
779 ' attr1="123"\n' +
780 ' data-attr2="hello t here"\n' +
781 ' heymanimreallylongtoowhocomesupwiththesenames="false"\n' +
782 '>This is some text</div>');
783 test_fragment(
784 '<img attr0 attr1="123" data-attr2="hello t here"/>',
785 // -- output --
786 '<img\n' +
787 ' attr0\n' +
788 ' attr1="123"\n' +
789 ' data-attr2="hello t here"\n' +
790 '/>');
791 test_fragment(
792 '<?xml version="1.0" encoding="UTF-8" ?><root attr1="foo" attr2="bar"/>',
793 // -- output --
794 '<?xml version="1.0" encoding="UTF-8" ?>\n' +
795 '<root\n' +
796 ' attr1="foo"\n' +
797 ' attr2="bar"\n' +
798 '/>');
799 test_fragment(
800 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin" rel="stylesheet" type="text/css">',
801 // -- output --
802 '<link\n' +
803 ' href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin"\n' +
804 ' rel="stylesheet"\n' +
805 ' type="text/css"\n' +
806 '>');
807  
808 // Attribute Wrap - (indent_attr = "\n ", indent_attr_first = "\n ", indent_end = "\n", indent_end_selfclosing = "\n", indent_over80 = "\n ")
809 reset_options();
810 opts.wrap_attributes = 'force-expand-multiline';
811 opts.wrap_attributes_indent_size = 8;
812 test_fragment('<div >This is some text</div>', '<div>This is some text</div>');
813 test_fragment('<div attr="123" >This is some text</div>', '<div attr="123">This is some text</div>');
814 test_fragment(
815 '<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>',
816 // -- output --
817 '<div\n' +
818 ' attr0\n' +
819 ' attr1="123"\n' +
820 ' data-attr2="hello t here"\n' +
821 '>This is some text</div>');
822 test_fragment(
823 '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>',
824 // -- output --
825 '<div\n' +
826 ' lookatthissuperduperlongattributenamewhoahcrazy0="true"\n' +
827 ' attr0\n' +
828 ' attr1="123"\n' +
829 ' data-attr2="hello t here"\n' +
830 ' heymanimreallylongtoowhocomesupwiththesenames="false"\n' +
831 '>This is some text</div>');
832 test_fragment(
833 '<img attr0 attr1="123" data-attr2="hello t here"/>',
834 // -- output --
835 '<img\n' +
836 ' attr0\n' +
837 ' attr1="123"\n' +
838 ' data-attr2="hello t here"\n' +
839 '/>');
840 test_fragment(
841 '<?xml version="1.0" encoding="UTF-8" ?><root attr1="foo" attr2="bar"/>',
842 // -- output --
843 '<?xml version="1.0" encoding="UTF-8" ?>\n' +
844 '<root\n' +
845 ' attr1="foo"\n' +
846 ' attr2="bar"\n' +
847 '/>');
848 test_fragment(
849 '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin" rel="stylesheet" type="text/css">',
850 // -- output --
851 '<link\n' +
852 ' href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin"\n' +
853 ' rel="stylesheet"\n' +
854 ' type="text/css"\n' +
855 '>');
856  
857  
858 //============================================================
859 // Handlebars Indenting Off
860 reset_options();
861 opts.indent_handlebars = false;
862 test_fragment(
863 '{{#if 0}}\n' +
864 ' <div>\n' +
865 ' </div>\n' +
866 '{{/if}}',
867 // -- output --
868 '{{#if 0}}\n' +
869 '<div>\n' +
870 '</div>\n' +
871 '{{/if}}');
872 test_fragment(
873 '<div>\n' +
874 '{{#each thing}}\n' +
875 ' {{name}}\n' +
876 '{{/each}}\n' +
877 '</div>',
878 // -- output --
879 '<div>\n' +
880 ' {{#each thing}} {{name}} {{/each}}\n' +
881 '</div>');
882  
883  
884 //============================================================
885 // Handlebars Indenting On - (content = "{{field}}")
886 reset_options();
887 opts.indent_handlebars = true;
888 test_fragment('{{page-title}}');
889 test_fragment('{{#if 0}}{{/if}}');
890 test_fragment('{{#if 0}}{{field}}{{/if}}');
891 test_fragment(
892 '{{#if 0}}\n' +
893 '{{/if}}');
894 test_fragment(
895 '{{#if words}}{{/if}}',
896 // -- output --
897 '{{#if words}}{{/if}}');
898 test_fragment(
899 '{{#if words}}{{field}}{{/if}}',
900 // -- output --
901 '{{#if words}}{{field}}{{/if}}');
902 test_fragment(
903 '{{#if words}}{{field}}{{/if}}',
904 // -- output --
905 '{{#if words}}{{field}}{{/if}}');
906 test_fragment(
907 '{{#if 1}}\n' +
908 ' <div>\n' +
909 ' </div>\n' +
910 '{{/if}}');
911 test_fragment(
912 '{{#if 1}}\n' +
913 '<div>\n' +
914 '</div>\n' +
915 '{{/if}}',
916 // -- output --
917 '{{#if 1}}\n' +
918 ' <div>\n' +
919 ' </div>\n' +
920 '{{/if}}');
921 test_fragment(
922 '<div>\n' +
923 ' {{#if 1}}\n' +
924 ' {{/if}}\n' +
925 '</div>');
926 test_fragment(
927 '<div>\n' +
928 '{{#if 1}}\n' +
929 '{{/if}}\n' +
930 '</div>',
931 // -- output --
932 '<div>\n' +
933 ' {{#if 1}}\n' +
934 ' {{/if}}\n' +
935 '</div>');
936 test_fragment(
937 '{{#if}}\n' +
938 '{{#each}}\n' +
939 '{{#if}}\n' +
940 '{{field}}\n' +
941 '{{/if}}\n' +
942 '{{#if}}\n' +
943 '{{field}}\n' +
944 '{{/if}}\n' +
945 '{{/each}}\n' +
946 '{{/if}}',
947 // -- output --
948 '{{#if}}\n' +
949 ' {{#each}}\n' +
950 ' {{#if}}\n' +
951 ' {{field}}\n' +
952 ' {{/if}}\n' +
953 ' {{#if}}\n' +
954 ' {{field}}\n' +
955 ' {{/if}}\n' +
956 ' {{/each}}\n' +
957 '{{/if}}');
958 test_fragment(
959 '{{#if 1}}\n' +
960 ' <div>\n' +
961 ' </div>\n' +
962 '{{/if}}');
963 test_fragment(
964 '{{#if 1}}\n' +
965 ' {{field}}\n' +
966 ' {{else}}\n' +
967 ' {{field}}\n' +
968 '{{/if}}',
969 // -- output --
970 '{{#if 1}}\n' +
971 ' {{field}}\n' +
972 '{{else}}\n' +
973 ' {{field}}\n' +
974 '{{/if}}');
975 test_fragment(
976 '{{#if 1}}\n' +
977 ' {{else}}\n' +
978 ' {{/if}}',
979 // -- output --
980 '{{#if 1}}\n' +
981 '{{else}}\n' +
982 '{{/if}}');
983 test_fragment(
984 '{{#if thing}}\n' +
985 '{{#if otherthing}}\n' +
986 ' {{field}}\n' +
987 ' {{else}}\n' +
988 '{{field}}\n' +
989 ' {{/if}}\n' +
990 ' {{else}}\n' +
991 '{{field}}\n' +
992 '{{/if}}',
993 // -- output --
994 '{{#if thing}}\n' +
995 ' {{#if otherthing}}\n' +
996 ' {{field}}\n' +
997 ' {{else}}\n' +
998 ' {{field}}\n' +
999 ' {{/if}}\n' +
1000 '{{else}}\n' +
1001 ' {{field}}\n' +
1002 '{{/if}}');
1003 test_fragment(
1004 '<div{{somestyle}}></div>',
1005 // -- output --
1006 '<div {{somestyle}}></div>');
1007 test_fragment(
1008 '<div{{#if test}}class="foo"{{/if}}>{{field}}</div>',
1009 // -- output --
1010 '<div {{#if test}} class="foo" {{/if}}>{{field}}</div>');
1011 test_fragment(
1012 '<div{{#if thing}}{{somestyle}}class="{{class}}"{{else}}class="{{class2}}"{{/if}}>{{field}}</div>',
1013 // -- output --
1014 '<div {{#if thing}} {{somestyle}} class="{{class}}" {{else}} class="{{class2}}" {{/if}}>{{field}}</div>');
1015 test_fragment(
1016 '<span{{#if condition}}class="foo"{{/if}}>{{field}}</span>',
1017 // -- output --
1018 '<span {{#if condition}} class="foo" {{/if}}>{{field}}</span>');
1019 test_fragment('<div unformatted="{{#if}}{{field}}{{/if}}">{{field}}</div>');
1020 test_fragment('<div unformatted="{{#if }} {{field}}{{/if}}">{{field}}</div>');
1021 test_fragment('<div class="{{#if thingIs "value"}}{{field}}{{/if}}"></div>');
1022 test_fragment('<div class="{{#if thingIs \'value\'}}{{field}}{{/if}}"></div>');
1023 test_fragment('<div class=\'{{#if thingIs "value"}}{{field}}{{/if}}\'></div>');
1024 test_fragment('<div class=\'{{#if thingIs \'value\'}}{{field}}{{/if}}\'></div>');
1025 test_fragment('<span>{{condition < 0 ? "result1" : "result2"}}</span>');
1026 test_fragment('<span>{{condition1 && condition2 && condition3 && condition4 < 0 ? "resForTrue" : "resForFalse"}}</span>');
1027  
1028 // Handlebars Indenting On - (content = "{{! comment}}")
1029 reset_options();
1030 opts.indent_handlebars = true;
1031 test_fragment('{{page-title}}');
1032 test_fragment('{{#if 0}}{{/if}}');
1033 test_fragment('{{#if 0}}{{! comment}}{{/if}}');
1034 test_fragment(
1035 '{{#if 0}}\n' +
1036 '{{/if}}');
1037 test_fragment(
1038 '{{#if words}}{{/if}}',
1039 // -- output --
1040 '{{#if words}}{{/if}}');
1041 test_fragment(
1042 '{{#if words}}{{! comment}}{{/if}}',
1043 // -- output --
1044 '{{#if words}}{{! comment}}{{/if}}');
1045 test_fragment(
1046 '{{#if words}}{{! comment}}{{/if}}',
1047 // -- output --
1048 '{{#if words}}{{! comment}}{{/if}}');
1049 test_fragment(
1050 '{{#if 1}}\n' +
1051 ' <div>\n' +
1052 ' </div>\n' +
1053 '{{/if}}');
1054 test_fragment(
1055 '{{#if 1}}\n' +
1056 '<div>\n' +
1057 '</div>\n' +
1058 '{{/if}}',
1059 // -- output --
1060 '{{#if 1}}\n' +
1061 ' <div>\n' +
1062 ' </div>\n' +
1063 '{{/if}}');
1064 test_fragment(
1065 '<div>\n' +
1066 ' {{#if 1}}\n' +
1067 ' {{/if}}\n' +
1068 '</div>');
1069 test_fragment(
1070 '<div>\n' +
1071 '{{#if 1}}\n' +
1072 '{{/if}}\n' +
1073 '</div>',
1074 // -- output --
1075 '<div>\n' +
1076 ' {{#if 1}}\n' +
1077 ' {{/if}}\n' +
1078 '</div>');
1079 test_fragment(
1080 '{{#if}}\n' +
1081 '{{#each}}\n' +
1082 '{{#if}}\n' +
1083 '{{! comment}}\n' +
1084 '{{/if}}\n' +
1085 '{{#if}}\n' +
1086 '{{! comment}}\n' +
1087 '{{/if}}\n' +
1088 '{{/each}}\n' +
1089 '{{/if}}',
1090 // -- output --
1091 '{{#if}}\n' +
1092 ' {{#each}}\n' +
1093 ' {{#if}}\n' +
1094 ' {{! comment}}\n' +
1095 ' {{/if}}\n' +
1096 ' {{#if}}\n' +
1097 ' {{! comment}}\n' +
1098 ' {{/if}}\n' +
1099 ' {{/each}}\n' +
1100 '{{/if}}');
1101 test_fragment(
1102 '{{#if 1}}\n' +
1103 ' <div>\n' +
1104 ' </div>\n' +
1105 '{{/if}}');
1106 test_fragment(
1107 '{{#if 1}}\n' +
1108 ' {{! comment}}\n' +
1109 ' {{else}}\n' +
1110 ' {{! comment}}\n' +
1111 '{{/if}}',
1112 // -- output --
1113 '{{#if 1}}\n' +
1114 ' {{! comment}}\n' +
1115 '{{else}}\n' +
1116 ' {{! comment}}\n' +
1117 '{{/if}}');
1118 test_fragment(
1119 '{{#if 1}}\n' +
1120 ' {{else}}\n' +
1121 ' {{/if}}',
1122 // -- output --
1123 '{{#if 1}}\n' +
1124 '{{else}}\n' +
1125 '{{/if}}');
1126 test_fragment(
1127 '{{#if thing}}\n' +
1128 '{{#if otherthing}}\n' +
1129 ' {{! comment}}\n' +
1130 ' {{else}}\n' +
1131 '{{! comment}}\n' +
1132 ' {{/if}}\n' +
1133 ' {{else}}\n' +
1134 '{{! comment}}\n' +
1135 '{{/if}}',
1136 // -- output --
1137 '{{#if thing}}\n' +
1138 ' {{#if otherthing}}\n' +
1139 ' {{! comment}}\n' +
1140 ' {{else}}\n' +
1141 ' {{! comment}}\n' +
1142 ' {{/if}}\n' +
1143 '{{else}}\n' +
1144 ' {{! comment}}\n' +
1145 '{{/if}}');
1146 test_fragment(
1147 '<div{{somestyle}}></div>',
1148 // -- output --
1149 '<div {{somestyle}}></div>');
1150 test_fragment(
1151 '<div{{#if test}}class="foo"{{/if}}>{{! comment}}</div>',
1152 // -- output --
1153 '<div {{#if test}} class="foo" {{/if}}>{{! comment}}</div>');
1154 test_fragment(
1155 '<div{{#if thing}}{{somestyle}}class="{{class}}"{{else}}class="{{class2}}"{{/if}}>{{! comment}}</div>',
1156 // -- output --
1157 '<div {{#if thing}} {{somestyle}} class="{{class}}" {{else}} class="{{class2}}" {{/if}}>{{! comment}}</div>');
1158 test_fragment(
1159 '<span{{#if condition}}class="foo"{{/if}}>{{! comment}}</span>',
1160 // -- output --
1161 '<span {{#if condition}} class="foo" {{/if}}>{{! comment}}</span>');
1162 test_fragment('<div unformatted="{{#if}}{{! comment}}{{/if}}">{{! comment}}</div>');
1163 test_fragment('<div unformatted="{{#if }} {{! comment}}{{/if}}">{{! comment}}</div>');
1164 test_fragment('<div class="{{#if thingIs "value"}}{{! comment}}{{/if}}"></div>');
1165 test_fragment('<div class="{{#if thingIs \'value\'}}{{! comment}}{{/if}}"></div>');
1166 test_fragment('<div class=\'{{#if thingIs "value"}}{{! comment}}{{/if}}\'></div>');
1167 test_fragment('<div class=\'{{#if thingIs \'value\'}}{{! comment}}{{/if}}\'></div>');
1168 test_fragment('<span>{{condition < 0 ? "result1" : "result2"}}</span>');
1169 test_fragment('<span>{{condition1 && condition2 && condition3 && condition4 < 0 ? "resForTrue" : "resForFalse"}}</span>');
1170  
1171 // Handlebars Indenting On - (content = "{{!-- comment--}}")
1172 reset_options();
1173 opts.indent_handlebars = true;
1174 test_fragment('{{page-title}}');
1175 test_fragment('{{#if 0}}{{/if}}');
1176 test_fragment('{{#if 0}}{{!-- comment--}}{{/if}}');
1177 test_fragment(
1178 '{{#if 0}}\n' +
1179 '{{/if}}');
1180 test_fragment(
1181 '{{#if words}}{{/if}}',
1182 // -- output --
1183 '{{#if words}}{{/if}}');
1184 test_fragment(
1185 '{{#if words}}{{!-- comment--}}{{/if}}',
1186 // -- output --
1187 '{{#if words}}{{!-- comment--}}{{/if}}');
1188 test_fragment(
1189 '{{#if words}}{{!-- comment--}}{{/if}}',
1190 // -- output --
1191 '{{#if words}}{{!-- comment--}}{{/if}}');
1192 test_fragment(
1193 '{{#if 1}}\n' +
1194 ' <div>\n' +
1195 ' </div>\n' +
1196 '{{/if}}');
1197 test_fragment(
1198 '{{#if 1}}\n' +
1199 '<div>\n' +
1200 '</div>\n' +
1201 '{{/if}}',
1202 // -- output --
1203 '{{#if 1}}\n' +
1204 ' <div>\n' +
1205 ' </div>\n' +
1206 '{{/if}}');
1207 test_fragment(
1208 '<div>\n' +
1209 ' {{#if 1}}\n' +
1210 ' {{/if}}\n' +
1211 '</div>');
1212 test_fragment(
1213 '<div>\n' +
1214 '{{#if 1}}\n' +
1215 '{{/if}}\n' +
1216 '</div>',
1217 // -- output --
1218 '<div>\n' +
1219 ' {{#if 1}}\n' +
1220 ' {{/if}}\n' +
1221 '</div>');
1222 test_fragment(
1223 '{{#if}}\n' +
1224 '{{#each}}\n' +
1225 '{{#if}}\n' +
1226 '{{!-- comment--}}\n' +
1227 '{{/if}}\n' +
1228 '{{#if}}\n' +
1229 '{{!-- comment--}}\n' +
1230 '{{/if}}\n' +
1231 '{{/each}}\n' +
1232 '{{/if}}',
1233 // -- output --
1234 '{{#if}}\n' +
1235 ' {{#each}}\n' +
1236 ' {{#if}}\n' +
1237 ' {{!-- comment--}}\n' +
1238 ' {{/if}}\n' +
1239 ' {{#if}}\n' +
1240 ' {{!-- comment--}}\n' +
1241 ' {{/if}}\n' +
1242 ' {{/each}}\n' +
1243 '{{/if}}');
1244 test_fragment(
1245 '{{#if 1}}\n' +
1246 ' <div>\n' +
1247 ' </div>\n' +
1248 '{{/if}}');
1249 test_fragment(
1250 '{{#if 1}}\n' +
1251 ' {{!-- comment--}}\n' +
1252 ' {{else}}\n' +
1253 ' {{!-- comment--}}\n' +
1254 '{{/if}}',
1255 // -- output --
1256 '{{#if 1}}\n' +
1257 ' {{!-- comment--}}\n' +
1258 '{{else}}\n' +
1259 ' {{!-- comment--}}\n' +
1260 '{{/if}}');
1261 test_fragment(
1262 '{{#if 1}}\n' +
1263 ' {{else}}\n' +
1264 ' {{/if}}',
1265 // -- output --
1266 '{{#if 1}}\n' +
1267 '{{else}}\n' +
1268 '{{/if}}');
1269 test_fragment(
1270 '{{#if thing}}\n' +
1271 '{{#if otherthing}}\n' +
1272 ' {{!-- comment--}}\n' +
1273 ' {{else}}\n' +
1274 '{{!-- comment--}}\n' +
1275 ' {{/if}}\n' +
1276 ' {{else}}\n' +
1277 '{{!-- comment--}}\n' +
1278 '{{/if}}',
1279 // -- output --
1280 '{{#if thing}}\n' +
1281 ' {{#if otherthing}}\n' +
1282 ' {{!-- comment--}}\n' +
1283 ' {{else}}\n' +
1284 ' {{!-- comment--}}\n' +
1285 ' {{/if}}\n' +
1286 '{{else}}\n' +
1287 ' {{!-- comment--}}\n' +
1288 '{{/if}}');
1289 test_fragment(
1290 '<div{{somestyle}}></div>',
1291 // -- output --
1292 '<div {{somestyle}}></div>');
1293 test_fragment(
1294 '<div{{#if test}}class="foo"{{/if}}>{{!-- comment--}}</div>',
1295 // -- output --
1296 '<div {{#if test}} class="foo" {{/if}}>{{!-- comment--}}</div>');
1297 test_fragment(
1298 '<div{{#if thing}}{{somestyle}}class="{{class}}"{{else}}class="{{class2}}"{{/if}}>{{!-- comment--}}</div>',
1299 // -- output --
1300 '<div {{#if thing}} {{somestyle}} class="{{class}}" {{else}} class="{{class2}}" {{/if}}>{{!-- comment--}}</div>');
1301 test_fragment(
1302 '<span{{#if condition}}class="foo"{{/if}}>{{!-- comment--}}</span>',
1303 // -- output --
1304 '<span {{#if condition}} class="foo" {{/if}}>{{!-- comment--}}</span>');
1305 test_fragment('<div unformatted="{{#if}}{{!-- comment--}}{{/if}}">{{!-- comment--}}</div>');
1306 test_fragment('<div unformatted="{{#if }} {{!-- comment--}}{{/if}}">{{!-- comment--}}</div>');
1307 test_fragment('<div class="{{#if thingIs "value"}}{{!-- comment--}}{{/if}}"></div>');
1308 test_fragment('<div class="{{#if thingIs \'value\'}}{{!-- comment--}}{{/if}}"></div>');
1309 test_fragment('<div class=\'{{#if thingIs "value"}}{{!-- comment--}}{{/if}}\'></div>');
1310 test_fragment('<div class=\'{{#if thingIs \'value\'}}{{!-- comment--}}{{/if}}\'></div>');
1311 test_fragment('<span>{{condition < 0 ? "result1" : "result2"}}</span>');
1312 test_fragment('<span>{{condition1 && condition2 && condition3 && condition4 < 0 ? "resForTrue" : "resForFalse"}}</span>');
1313  
1314 // Handlebars Indenting On - (content = "{pre{{field1}} {{field2}} {{field3}}post")
1315 reset_options();
1316 opts.indent_handlebars = true;
1317 test_fragment('{{page-title}}');
1318 test_fragment('{{#if 0}}{{/if}}');
1319 test_fragment('{{#if 0}}{pre{{field1}} {{field2}} {{field3}}post{{/if}}');
1320 test_fragment(
1321 '{{#if 0}}\n' +
1322 '{{/if}}');
1323 test_fragment(
1324 '{{#if words}}{{/if}}',
1325 // -- output --
1326 '{{#if words}}{{/if}}');
1327 test_fragment(
1328 '{{#if words}}{pre{{field1}} {{field2}} {{field3}}post{{/if}}',
1329 // -- output --
1330 '{{#if words}}{pre{{field1}} {{field2}} {{field3}}post{{/if}}');
1331 test_fragment(
1332 '{{#if words}}{pre{{field1}} {{field2}} {{field3}}post{{/if}}',
1333 // -- output --
1334 '{{#if words}}{pre{{field1}} {{field2}} {{field3}}post{{/if}}');
1335 test_fragment(
1336 '{{#if 1}}\n' +
1337 ' <div>\n' +
1338 ' </div>\n' +
1339 '{{/if}}');
1340 test_fragment(
1341 '{{#if 1}}\n' +
1342 '<div>\n' +
1343 '</div>\n' +
1344 '{{/if}}',
1345 // -- output --
1346 '{{#if 1}}\n' +
1347 ' <div>\n' +
1348 ' </div>\n' +
1349 '{{/if}}');
1350 test_fragment(
1351 '<div>\n' +
1352 ' {{#if 1}}\n' +
1353 ' {{/if}}\n' +
1354 '</div>');
1355 test_fragment(
1356 '<div>\n' +
1357 '{{#if 1}}\n' +
1358 '{{/if}}\n' +
1359 '</div>',
1360 // -- output --
1361 '<div>\n' +
1362 ' {{#if 1}}\n' +
1363 ' {{/if}}\n' +
1364 '</div>');
1365 test_fragment(
1366 '{{#if}}\n' +
1367 '{{#each}}\n' +
1368 '{{#if}}\n' +
1369 '{pre{{field1}} {{field2}} {{field3}}post\n' +
1370 '{{/if}}\n' +
1371 '{{#if}}\n' +
1372 '{pre{{field1}} {{field2}} {{field3}}post\n' +
1373 '{{/if}}\n' +
1374 '{{/each}}\n' +
1375 '{{/if}}',
1376 // -- output --
1377 '{{#if}}\n' +
1378 ' {{#each}}\n' +
1379 ' {{#if}}\n' +
1380 ' {pre{{field1}} {{field2}} {{field3}}post\n' +
1381 ' {{/if}}\n' +
1382 ' {{#if}}\n' +
1383 ' {pre{{field1}} {{field2}} {{field3}}post\n' +
1384 ' {{/if}}\n' +
1385 ' {{/each}}\n' +
1386 '{{/if}}');
1387 test_fragment(
1388 '{{#if 1}}\n' +
1389 ' <div>\n' +
1390 ' </div>\n' +
1391 '{{/if}}');
1392 test_fragment(
1393 '{{#if 1}}\n' +
1394 ' {pre{{field1}} {{field2}} {{field3}}post\n' +
1395 ' {{else}}\n' +
1396 ' {pre{{field1}} {{field2}} {{field3}}post\n' +
1397 '{{/if}}',
1398 // -- output --
1399 '{{#if 1}}\n' +
1400 ' {pre{{field1}} {{field2}} {{field3}}post\n' +
1401 '{{else}}\n' +
1402 ' {pre{{field1}} {{field2}} {{field3}}post\n' +
1403 '{{/if}}');
1404 test_fragment(
1405 '{{#if 1}}\n' +
1406 ' {{else}}\n' +
1407 ' {{/if}}',
1408 // -- output --
1409 '{{#if 1}}\n' +
1410 '{{else}}\n' +
1411 '{{/if}}');
1412 test_fragment(
1413 '{{#if thing}}\n' +
1414 '{{#if otherthing}}\n' +
1415 ' {pre{{field1}} {{field2}} {{field3}}post\n' +
1416 ' {{else}}\n' +
1417 '{pre{{field1}} {{field2}} {{field3}}post\n' +
1418 ' {{/if}}\n' +
1419 ' {{else}}\n' +
1420 '{pre{{field1}} {{field2}} {{field3}}post\n' +
1421 '{{/if}}',
1422 // -- output --
1423 '{{#if thing}}\n' +
1424 ' {{#if otherthing}}\n' +
1425 ' {pre{{field1}} {{field2}} {{field3}}post\n' +
1426 ' {{else}}\n' +
1427 ' {pre{{field1}} {{field2}} {{field3}}post\n' +
1428 ' {{/if}}\n' +
1429 '{{else}}\n' +
1430 ' {pre{{field1}} {{field2}} {{field3}}post\n' +
1431 '{{/if}}');
1432 test_fragment(
1433 '<div{{somestyle}}></div>',
1434 // -- output --
1435 '<div {{somestyle}}></div>');
1436 test_fragment(
1437 '<div{{#if test}}class="foo"{{/if}}>{pre{{field1}} {{field2}} {{field3}}post</div>',
1438 // -- output --
1439 '<div {{#if test}} class="foo" {{/if}}>{pre{{field1}} {{field2}} {{field3}}post</div>');
1440 test_fragment(
1441 '<div{{#if thing}}{{somestyle}}class="{{class}}"{{else}}class="{{class2}}"{{/if}}>{pre{{field1}} {{field2}} {{field3}}post</div>',
1442 // -- output --
1443 '<div {{#if thing}} {{somestyle}} class="{{class}}" {{else}} class="{{class2}}" {{/if}}>{pre{{field1}} {{field2}} {{field3}}post</div>');
1444 test_fragment(
1445 '<span{{#if condition}}class="foo"{{/if}}>{pre{{field1}} {{field2}} {{field3}}post</span>',
1446 // -- output --
1447 '<span {{#if condition}} class="foo" {{/if}}>{pre{{field1}} {{field2}} {{field3}}post</span>');
1448 test_fragment('<div unformatted="{{#if}}{pre{{field1}} {{field2}} {{field3}}post{{/if}}">{pre{{field1}} {{field2}} {{field3}}post</div>');
1449 test_fragment('<div unformatted="{{#if }} {pre{{field1}} {{field2}} {{field3}}post{{/if}}">{pre{{field1}} {{field2}} {{field3}}post</div>');
1450 test_fragment('<div class="{{#if thingIs "value"}}{pre{{field1}} {{field2}} {{field3}}post{{/if}}"></div>');
1451 test_fragment('<div class="{{#if thingIs \'value\'}}{pre{{field1}} {{field2}} {{field3}}post{{/if}}"></div>');
1452 test_fragment('<div class=\'{{#if thingIs "value"}}{pre{{field1}} {{field2}} {{field3}}post{{/if}}\'></div>');
1453 test_fragment('<div class=\'{{#if thingIs \'value\'}}{pre{{field1}} {{field2}} {{field3}}post{{/if}}\'></div>');
1454 test_fragment('<span>{{condition < 0 ? "result1" : "result2"}}</span>');
1455 test_fragment('<span>{{condition1 && condition2 && condition3 && condition4 < 0 ? "resForTrue" : "resForFalse"}}</span>');
1456  
1457 // Handlebars Indenting On - (content = "{{! \n mult-line\ncomment \n with spacing\n}}")
1458 reset_options();
1459 opts.indent_handlebars = true;
1460 test_fragment('{{page-title}}');
1461 test_fragment('{{#if 0}}{{/if}}');
1462 test_fragment(
1463 '{{#if 0}}{{! \n' +
1464 ' mult-line\n' +
1465 'comment \n' +
1466 ' with spacing\n' +
1467 '}}{{/if}}');
1468 test_fragment(
1469 '{{#if 0}}\n' +
1470 '{{/if}}');
1471 test_fragment(
1472 '{{#if words}}{{/if}}',
1473 // -- output --
1474 '{{#if words}}{{/if}}');
1475 test_fragment(
1476 '{{#if words}}{{! \n' +
1477 ' mult-line\n' +
1478 'comment \n' +
1479 ' with spacing\n' +
1480 '}}{{/if}}',
1481 // -- output --
1482 '{{#if words}}{{! \n' +
1483 ' mult-line\n' +
1484 'comment \n' +
1485 ' with spacing\n' +
1486 '}}{{/if}}');
1487 test_fragment(
1488 '{{#if words}}{{! \n' +
1489 ' mult-line\n' +
1490 'comment \n' +
1491 ' with spacing\n' +
1492 '}}{{/if}}',
1493 // -- output --
1494 '{{#if words}}{{! \n' +
1495 ' mult-line\n' +
1496 'comment \n' +
1497 ' with spacing\n' +
1498 '}}{{/if}}');
1499 test_fragment(
1500 '{{#if 1}}\n' +
1501 ' <div>\n' +
1502 ' </div>\n' +
1503 '{{/if}}');
1504 test_fragment(
1505 '{{#if 1}}\n' +
1506 '<div>\n' +
1507 '</div>\n' +
1508 '{{/if}}',
1509 // -- output --
1510 '{{#if 1}}\n' +
1511 ' <div>\n' +
1512 ' </div>\n' +
1513 '{{/if}}');
1514 test_fragment(
1515 '<div>\n' +
1516 ' {{#if 1}}\n' +
1517 ' {{/if}}\n' +
1518 '</div>');
1519 test_fragment(
1520 '<div>\n' +
1521 '{{#if 1}}\n' +
1522 '{{/if}}\n' +
1523 '</div>',
1524 // -- output --
1525 '<div>\n' +
1526 ' {{#if 1}}\n' +
1527 ' {{/if}}\n' +
1528 '</div>');
1529 test_fragment(
1530 '{{#if}}\n' +
1531 '{{#each}}\n' +
1532 '{{#if}}\n' +
1533 '{{! \n' +
1534 ' mult-line\n' +
1535 'comment \n' +
1536 ' with spacing\n' +
1537 '}}\n' +
1538 '{{/if}}\n' +
1539 '{{#if}}\n' +
1540 '{{! \n' +
1541 ' mult-line\n' +
1542 'comment \n' +
1543 ' with spacing\n' +
1544 '}}\n' +
1545 '{{/if}}\n' +
1546 '{{/each}}\n' +
1547 '{{/if}}',
1548 // -- output --
1549 '{{#if}}\n' +
1550 ' {{#each}}\n' +
1551 ' {{#if}}\n' +
1552 ' {{! \n' +
1553 ' mult-line\n' +
1554 'comment \n' +
1555 ' with spacing\n' +
1556 '}}\n' +
1557 ' {{/if}}\n' +
1558 ' {{#if}}\n' +
1559 ' {{! \n' +
1560 ' mult-line\n' +
1561 'comment \n' +
1562 ' with spacing\n' +
1563 '}}\n' +
1564 ' {{/if}}\n' +
1565 ' {{/each}}\n' +
1566 '{{/if}}');
1567 test_fragment(
1568 '{{#if 1}}\n' +
1569 ' <div>\n' +
1570 ' </div>\n' +
1571 '{{/if}}');
1572 test_fragment(
1573 '{{#if 1}}\n' +
1574 ' {{! \n' +
1575 ' mult-line\n' +
1576 'comment \n' +
1577 ' with spacing\n' +
1578 '}}\n' +
1579 ' {{else}}\n' +
1580 ' {{! \n' +
1581 ' mult-line\n' +
1582 'comment \n' +
1583 ' with spacing\n' +
1584 '}}\n' +
1585 '{{/if}}',
1586 // -- output --
1587 '{{#if 1}}\n' +
1588 ' {{! \n' +
1589 ' mult-line\n' +
1590 'comment \n' +
1591 ' with spacing\n' +
1592 '}}\n' +
1593 '{{else}}\n' +
1594 ' {{! \n' +
1595 ' mult-line\n' +
1596 'comment \n' +
1597 ' with spacing\n' +
1598 '}}\n' +
1599 '{{/if}}');
1600 test_fragment(
1601 '{{#if 1}}\n' +
1602 ' {{else}}\n' +
1603 ' {{/if}}',
1604 // -- output --
1605 '{{#if 1}}\n' +
1606 '{{else}}\n' +
1607 '{{/if}}');
1608 test_fragment(
1609 '{{#if thing}}\n' +
1610 '{{#if otherthing}}\n' +
1611 ' {{! \n' +
1612 ' mult-line\n' +
1613 'comment \n' +
1614 ' with spacing\n' +
1615 '}}\n' +
1616 ' {{else}}\n' +
1617 '{{! \n' +
1618 ' mult-line\n' +
1619 'comment \n' +
1620 ' with spacing\n' +
1621 '}}\n' +
1622 ' {{/if}}\n' +
1623 ' {{else}}\n' +
1624 '{{! \n' +
1625 ' mult-line\n' +
1626 'comment \n' +
1627 ' with spacing\n' +
1628 '}}\n' +
1629 '{{/if}}',
1630 // -- output --
1631 '{{#if thing}}\n' +
1632 ' {{#if otherthing}}\n' +
1633 ' {{! \n' +
1634 ' mult-line\n' +
1635 'comment \n' +
1636 ' with spacing\n' +
1637 '}}\n' +
1638 ' {{else}}\n' +
1639 ' {{! \n' +
1640 ' mult-line\n' +
1641 'comment \n' +
1642 ' with spacing\n' +
1643 '}}\n' +
1644 ' {{/if}}\n' +
1645 '{{else}}\n' +
1646 ' {{! \n' +
1647 ' mult-line\n' +
1648 'comment \n' +
1649 ' with spacing\n' +
1650 '}}\n' +
1651 '{{/if}}');
1652 test_fragment(
1653 '<div{{somestyle}}></div>',
1654 // -- output --
1655 '<div {{somestyle}}></div>');
1656 test_fragment(
1657 '<div{{#if test}}class="foo"{{/if}}>{{! \n' +
1658 ' mult-line\n' +
1659 'comment \n' +
1660 ' with spacing\n' +
1661 '}}</div>',
1662 // -- output --
1663 '<div {{#if test}} class="foo" {{/if}}>{{! \n' +
1664 ' mult-line\n' +
1665 'comment \n' +
1666 ' with spacing\n' +
1667 '}}</div>');
1668 test_fragment(
1669 '<div{{#if thing}}{{somestyle}}class="{{class}}"{{else}}class="{{class2}}"{{/if}}>{{! \n' +
1670 ' mult-line\n' +
1671 'comment \n' +
1672 ' with spacing\n' +
1673 '}}</div>',
1674 // -- output --
1675 '<div {{#if thing}} {{somestyle}} class="{{class}}" {{else}} class="{{class2}}" {{/if}}>{{! \n' +
1676 ' mult-line\n' +
1677 'comment \n' +
1678 ' with spacing\n' +
1679 '}}</div>');
1680 test_fragment(
1681 '<span{{#if condition}}class="foo"{{/if}}>{{! \n' +
1682 ' mult-line\n' +
1683 'comment \n' +
1684 ' with spacing\n' +
1685 '}}</span>',
1686 // -- output --
1687 '<span {{#if condition}} class="foo" {{/if}}>{{! \n' +
1688 ' mult-line\n' +
1689 'comment \n' +
1690 ' with spacing\n' +
1691 '}}</span>');
1692 test_fragment(
1693 '<div unformatted="{{#if}}{{! \n' +
1694 ' mult-line\n' +
1695 'comment \n' +
1696 ' with spacing\n' +
1697 '}}{{/if}}">{{! \n' +
1698 ' mult-line\n' +
1699 'comment \n' +
1700 ' with spacing\n' +
1701 '}}</div>');
1702 test_fragment(
1703 '<div unformatted="{{#if }} {{! \n' +
1704 ' mult-line\n' +
1705 'comment \n' +
1706 ' with spacing\n' +
1707 '}}{{/if}}">{{! \n' +
1708 ' mult-line\n' +
1709 'comment \n' +
1710 ' with spacing\n' +
1711 '}}</div>');
1712 test_fragment(
1713 '<div class="{{#if thingIs "value"}}{{! \n' +
1714 ' mult-line\n' +
1715 'comment \n' +
1716 ' with spacing\n' +
1717 '}}{{/if}}"></div>');
1718 test_fragment(
1719 '<div class="{{#if thingIs \'value\'}}{{! \n' +
1720 ' mult-line\n' +
1721 'comment \n' +
1722 ' with spacing\n' +
1723 '}}{{/if}}"></div>');
1724 test_fragment(
1725 '<div class=\'{{#if thingIs "value"}}{{! \n' +
1726 ' mult-line\n' +
1727 'comment \n' +
1728 ' with spacing\n' +
1729 '}}{{/if}}\'></div>');
1730 test_fragment(
1731 '<div class=\'{{#if thingIs \'value\'}}{{! \n' +
1732 ' mult-line\n' +
1733 'comment \n' +
1734 ' with spacing\n' +
1735 '}}{{/if}}\'></div>');
1736 test_fragment('<span>{{condition < 0 ? "result1" : "result2"}}</span>');
1737 test_fragment('<span>{{condition1 && condition2 && condition3 && condition4 < 0 ? "resForTrue" : "resForFalse"}}</span>');
1738  
1739 // Handlebars Indenting On - (content = "{{!-- \n mult-line\ncomment \n with spacing\n--}}")
1740 reset_options();
1741 opts.indent_handlebars = true;
1742 test_fragment('{{page-title}}');
1743 test_fragment('{{#if 0}}{{/if}}');
1744 test_fragment(
1745 '{{#if 0}}{{!-- \n' +
1746 ' mult-line\n' +
1747 'comment \n' +
1748 ' with spacing\n' +
1749 '--}}{{/if}}');
1750 test_fragment(
1751 '{{#if 0}}\n' +
1752 '{{/if}}');
1753 test_fragment(
1754 '{{#if words}}{{/if}}',
1755 // -- output --
1756 '{{#if words}}{{/if}}');
1757 test_fragment(
1758 '{{#if words}}{{!-- \n' +
1759 ' mult-line\n' +
1760 'comment \n' +
1761 ' with spacing\n' +
1762 '--}}{{/if}}',
1763 // -- output --
1764 '{{#if words}}{{!-- \n' +
1765 ' mult-line\n' +
1766 'comment \n' +
1767 ' with spacing\n' +
1768 '--}}{{/if}}');
1769 test_fragment(
1770 '{{#if words}}{{!-- \n' +
1771 ' mult-line\n' +
1772 'comment \n' +
1773 ' with spacing\n' +
1774 '--}}{{/if}}',
1775 // -- output --
1776 '{{#if words}}{{!-- \n' +
1777 ' mult-line\n' +
1778 'comment \n' +
1779 ' with spacing\n' +
1780 '--}}{{/if}}');
1781 test_fragment(
1782 '{{#if 1}}\n' +
1783 ' <div>\n' +
1784 ' </div>\n' +
1785 '{{/if}}');
1786 test_fragment(
1787 '{{#if 1}}\n' +
1788 '<div>\n' +
1789 '</div>\n' +
1790 '{{/if}}',
1791 // -- output --
1792 '{{#if 1}}\n' +
1793 ' <div>\n' +
1794 ' </div>\n' +
1795 '{{/if}}');
1796 test_fragment(
1797 '<div>\n' +
1798 ' {{#if 1}}\n' +
1799 ' {{/if}}\n' +
1800 '</div>');
1801 test_fragment(
1802 '<div>\n' +
1803 '{{#if 1}}\n' +
1804 '{{/if}}\n' +
1805 '</div>',
1806 // -- output --
1807 '<div>\n' +
1808 ' {{#if 1}}\n' +
1809 ' {{/if}}\n' +
1810 '</div>');
1811 test_fragment(
1812 '{{#if}}\n' +
1813 '{{#each}}\n' +
1814 '{{#if}}\n' +
1815 '{{!-- \n' +
1816 ' mult-line\n' +
1817 'comment \n' +
1818 ' with spacing\n' +
1819 '--}}\n' +
1820 '{{/if}}\n' +
1821 '{{#if}}\n' +
1822 '{{!-- \n' +
1823 ' mult-line\n' +
1824 'comment \n' +
1825 ' with spacing\n' +
1826 '--}}\n' +
1827 '{{/if}}\n' +
1828 '{{/each}}\n' +
1829 '{{/if}}',
1830 // -- output --
1831 '{{#if}}\n' +
1832 ' {{#each}}\n' +
1833 ' {{#if}}\n' +
1834 ' {{!-- \n' +
1835 ' mult-line\n' +
1836 'comment \n' +
1837 ' with spacing\n' +
1838 '--}}\n' +
1839 ' {{/if}}\n' +
1840 ' {{#if}}\n' +
1841 ' {{!-- \n' +
1842 ' mult-line\n' +
1843 'comment \n' +
1844 ' with spacing\n' +
1845 '--}}\n' +
1846 ' {{/if}}\n' +
1847 ' {{/each}}\n' +
1848 '{{/if}}');
1849 test_fragment(
1850 '{{#if 1}}\n' +
1851 ' <div>\n' +
1852 ' </div>\n' +
1853 '{{/if}}');
1854 test_fragment(
1855 '{{#if 1}}\n' +
1856 ' {{!-- \n' +
1857 ' mult-line\n' +
1858 'comment \n' +
1859 ' with spacing\n' +
1860 '--}}\n' +
1861 ' {{else}}\n' +
1862 ' {{!-- \n' +
1863 ' mult-line\n' +
1864 'comment \n' +
1865 ' with spacing\n' +
1866 '--}}\n' +
1867 '{{/if}}',
1868 // -- output --
1869 '{{#if 1}}\n' +
1870 ' {{!-- \n' +
1871 ' mult-line\n' +
1872 'comment \n' +
1873 ' with spacing\n' +
1874 '--}}\n' +
1875 '{{else}}\n' +
1876 ' {{!-- \n' +
1877 ' mult-line\n' +
1878 'comment \n' +
1879 ' with spacing\n' +
1880 '--}}\n' +
1881 '{{/if}}');
1882 test_fragment(
1883 '{{#if 1}}\n' +
1884 ' {{else}}\n' +
1885 ' {{/if}}',
1886 // -- output --
1887 '{{#if 1}}\n' +
1888 '{{else}}\n' +
1889 '{{/if}}');
1890 test_fragment(
1891 '{{#if thing}}\n' +
1892 '{{#if otherthing}}\n' +
1893 ' {{!-- \n' +
1894 ' mult-line\n' +
1895 'comment \n' +
1896 ' with spacing\n' +
1897 '--}}\n' +
1898 ' {{else}}\n' +
1899 '{{!-- \n' +
1900 ' mult-line\n' +
1901 'comment \n' +
1902 ' with spacing\n' +
1903 '--}}\n' +
1904 ' {{/if}}\n' +
1905 ' {{else}}\n' +
1906 '{{!-- \n' +
1907 ' mult-line\n' +
1908 'comment \n' +
1909 ' with spacing\n' +
1910 '--}}\n' +
1911 '{{/if}}',
1912 // -- output --
1913 '{{#if thing}}\n' +
1914 ' {{#if otherthing}}\n' +
1915 ' {{!-- \n' +
1916 ' mult-line\n' +
1917 'comment \n' +
1918 ' with spacing\n' +
1919 '--}}\n' +
1920 ' {{else}}\n' +
1921 ' {{!-- \n' +
1922 ' mult-line\n' +
1923 'comment \n' +
1924 ' with spacing\n' +
1925 '--}}\n' +
1926 ' {{/if}}\n' +
1927 '{{else}}\n' +
1928 ' {{!-- \n' +
1929 ' mult-line\n' +
1930 'comment \n' +
1931 ' with spacing\n' +
1932 '--}}\n' +
1933 '{{/if}}');
1934 test_fragment(
1935 '<div{{somestyle}}></div>',
1936 // -- output --
1937 '<div {{somestyle}}></div>');
1938 test_fragment(
1939 '<div{{#if test}}class="foo"{{/if}}>{{!-- \n' +
1940 ' mult-line\n' +
1941 'comment \n' +
1942 ' with spacing\n' +
1943 '--}}</div>',
1944 // -- output --
1945 '<div {{#if test}} class="foo" {{/if}}>{{!-- \n' +
1946 ' mult-line\n' +
1947 'comment \n' +
1948 ' with spacing\n' +
1949 '--}}</div>');
1950 test_fragment(
1951 '<div{{#if thing}}{{somestyle}}class="{{class}}"{{else}}class="{{class2}}"{{/if}}>{{!-- \n' +
1952 ' mult-line\n' +
1953 'comment \n' +
1954 ' with spacing\n' +
1955 '--}}</div>',
1956 // -- output --
1957 '<div {{#if thing}} {{somestyle}} class="{{class}}" {{else}} class="{{class2}}" {{/if}}>{{!-- \n' +
1958 ' mult-line\n' +
1959 'comment \n' +
1960 ' with spacing\n' +
1961 '--}}</div>');
1962 test_fragment(
1963 '<span{{#if condition}}class="foo"{{/if}}>{{!-- \n' +
1964 ' mult-line\n' +
1965 'comment \n' +
1966 ' with spacing\n' +
1967 '--}}</span>',
1968 // -- output --
1969 '<span {{#if condition}} class="foo" {{/if}}>{{!-- \n' +
1970 ' mult-line\n' +
1971 'comment \n' +
1972 ' with spacing\n' +
1973 '--}}</span>');
1974 test_fragment(
1975 '<div unformatted="{{#if}}{{!-- \n' +
1976 ' mult-line\n' +
1977 'comment \n' +
1978 ' with spacing\n' +
1979 '--}}{{/if}}">{{!-- \n' +
1980 ' mult-line\n' +
1981 'comment \n' +
1982 ' with spacing\n' +
1983 '--}}</div>');
1984 test_fragment(
1985 '<div unformatted="{{#if }} {{!-- \n' +
1986 ' mult-line\n' +
1987 'comment \n' +
1988 ' with spacing\n' +
1989 '--}}{{/if}}">{{!-- \n' +
1990 ' mult-line\n' +
1991 'comment \n' +
1992 ' with spacing\n' +
1993 '--}}</div>');
1994 test_fragment(
1995 '<div class="{{#if thingIs "value"}}{{!-- \n' +
1996 ' mult-line\n' +
1997 'comment \n' +
1998 ' with spacing\n' +
1999 '--}}{{/if}}"></div>');
2000 test_fragment(
2001 '<div class="{{#if thingIs \'value\'}}{{!-- \n' +
2002 ' mult-line\n' +
2003 'comment \n' +
2004 ' with spacing\n' +
2005 '--}}{{/if}}"></div>');
2006 test_fragment(
2007 '<div class=\'{{#if thingIs "value"}}{{!-- \n' +
2008 ' mult-line\n' +
2009 'comment \n' +
2010 ' with spacing\n' +
2011 '--}}{{/if}}\'></div>');
2012 test_fragment(
2013 '<div class=\'{{#if thingIs \'value\'}}{{!-- \n' +
2014 ' mult-line\n' +
2015 'comment \n' +
2016 ' with spacing\n' +
2017 '--}}{{/if}}\'></div>');
2018 test_fragment('<span>{{condition < 0 ? "result1" : "result2"}}</span>');
2019 test_fragment('<span>{{condition1 && condition2 && condition3 && condition4 < 0 ? "resForTrue" : "resForFalse"}}</span>');
2020  
2021 // Handlebars Indenting On - (content = "{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}")
2022 reset_options();
2023 opts.indent_handlebars = true;
2024 test_fragment('{{page-title}}');
2025 test_fragment('{{#if 0}}{{/if}}');
2026 test_fragment(
2027 '{{#if 0}}{{!-- \n' +
2028 ' mult-line\n' +
2029 'comment \n' +
2030 '{{#> component}}\n' +
2031 ' mult-line\n' +
2032 'comment \n' +
2033 ' with spacing\n' +
2034 ' {{/ component}}--}}{{/if}}');
2035 test_fragment(
2036 '{{#if 0}}\n' +
2037 '{{/if}}');
2038 test_fragment(
2039 '{{#if words}}{{/if}}',
2040 // -- output --
2041 '{{#if words}}{{/if}}');
2042 test_fragment(
2043 '{{#if words}}{{!-- \n' +
2044 ' mult-line\n' +
2045 'comment \n' +
2046 '{{#> component}}\n' +
2047 ' mult-line\n' +
2048 'comment \n' +
2049 ' with spacing\n' +
2050 ' {{/ component}}--}}{{/if}}',
2051 // -- output --
2052 '{{#if words}}{{!-- \n' +
2053 ' mult-line\n' +
2054 'comment \n' +
2055 '{{#> component}}\n' +
2056 ' mult-line\n' +
2057 'comment \n' +
2058 ' with spacing\n' +
2059 ' {{/ component}}--}}{{/if}}');
2060 test_fragment(
2061 '{{#if words}}{{!-- \n' +
2062 ' mult-line\n' +
2063 'comment \n' +
2064 '{{#> component}}\n' +
2065 ' mult-line\n' +
2066 'comment \n' +
2067 ' with spacing\n' +
2068 ' {{/ component}}--}}{{/if}}',
2069 // -- output --
2070 '{{#if words}}{{!-- \n' +
2071 ' mult-line\n' +
2072 'comment \n' +
2073 '{{#> component}}\n' +
2074 ' mult-line\n' +
2075 'comment \n' +
2076 ' with spacing\n' +
2077 ' {{/ component}}--}}{{/if}}');
2078 test_fragment(
2079 '{{#if 1}}\n' +
2080 ' <div>\n' +
2081 ' </div>\n' +
2082 '{{/if}}');
2083 test_fragment(
2084 '{{#if 1}}\n' +
2085 '<div>\n' +
2086 '</div>\n' +
2087 '{{/if}}',
2088 // -- output --
2089 '{{#if 1}}\n' +
2090 ' <div>\n' +
2091 ' </div>\n' +
2092 '{{/if}}');
2093 test_fragment(
2094 '<div>\n' +
2095 ' {{#if 1}}\n' +
2096 ' {{/if}}\n' +
2097 '</div>');
2098 test_fragment(
2099 '<div>\n' +
2100 '{{#if 1}}\n' +
2101 '{{/if}}\n' +
2102 '</div>',
2103 // -- output --
2104 '<div>\n' +
2105 ' {{#if 1}}\n' +
2106 ' {{/if}}\n' +
2107 '</div>');
2108 test_fragment(
2109 '{{#if}}\n' +
2110 '{{#each}}\n' +
2111 '{{#if}}\n' +
2112 '{{!-- \n' +
2113 ' mult-line\n' +
2114 'comment \n' +
2115 '{{#> component}}\n' +
2116 ' mult-line\n' +
2117 'comment \n' +
2118 ' with spacing\n' +
2119 ' {{/ component}}--}}\n' +
2120 '{{/if}}\n' +
2121 '{{#if}}\n' +
2122 '{{!-- \n' +
2123 ' mult-line\n' +
2124 'comment \n' +
2125 '{{#> component}}\n' +
2126 ' mult-line\n' +
2127 'comment \n' +
2128 ' with spacing\n' +
2129 ' {{/ component}}--}}\n' +
2130 '{{/if}}\n' +
2131 '{{/each}}\n' +
2132 '{{/if}}',
2133 // -- output --
2134 '{{#if}}\n' +
2135 ' {{#each}}\n' +
2136 ' {{#if}}\n' +
2137 ' {{!-- \n' +
2138 ' mult-line\n' +
2139 'comment \n' +
2140 '{{#> component}}\n' +
2141 ' mult-line\n' +
2142 'comment \n' +
2143 ' with spacing\n' +
2144 ' {{/ component}}--}}\n' +
2145 ' {{/if}}\n' +
2146 ' {{#if}}\n' +
2147 ' {{!-- \n' +
2148 ' mult-line\n' +
2149 'comment \n' +
2150 '{{#> component}}\n' +
2151 ' mult-line\n' +
2152 'comment \n' +
2153 ' with spacing\n' +
2154 ' {{/ component}}--}}\n' +
2155 ' {{/if}}\n' +
2156 ' {{/each}}\n' +
2157 '{{/if}}');
2158 test_fragment(
2159 '{{#if 1}}\n' +
2160 ' <div>\n' +
2161 ' </div>\n' +
2162 '{{/if}}');
2163 test_fragment(
2164 '{{#if 1}}\n' +
2165 ' {{!-- \n' +
2166 ' mult-line\n' +
2167 'comment \n' +
2168 '{{#> component}}\n' +
2169 ' mult-line\n' +
2170 'comment \n' +
2171 ' with spacing\n' +
2172 ' {{/ component}}--}}\n' +
2173 ' {{else}}\n' +
2174 ' {{!-- \n' +
2175 ' mult-line\n' +
2176 'comment \n' +
2177 '{{#> component}}\n' +
2178 ' mult-line\n' +
2179 'comment \n' +
2180 ' with spacing\n' +
2181 ' {{/ component}}--}}\n' +
2182 '{{/if}}',
2183 // -- output --
2184 '{{#if 1}}\n' +
2185 ' {{!-- \n' +
2186 ' mult-line\n' +
2187 'comment \n' +
2188 '{{#> component}}\n' +
2189 ' mult-line\n' +
2190 'comment \n' +
2191 ' with spacing\n' +
2192 ' {{/ component}}--}}\n' +
2193 '{{else}}\n' +
2194 ' {{!-- \n' +
2195 ' mult-line\n' +
2196 'comment \n' +
2197 '{{#> component}}\n' +
2198 ' mult-line\n' +
2199 'comment \n' +
2200 ' with spacing\n' +
2201 ' {{/ component}}--}}\n' +
2202 '{{/if}}');
2203 test_fragment(
2204 '{{#if 1}}\n' +
2205 ' {{else}}\n' +
2206 ' {{/if}}',
2207 // -- output --
2208 '{{#if 1}}\n' +
2209 '{{else}}\n' +
2210 '{{/if}}');
2211 test_fragment(
2212 '{{#if thing}}\n' +
2213 '{{#if otherthing}}\n' +
2214 ' {{!-- \n' +
2215 ' mult-line\n' +
2216 'comment \n' +
2217 '{{#> component}}\n' +
2218 ' mult-line\n' +
2219 'comment \n' +
2220 ' with spacing\n' +
2221 ' {{/ component}}--}}\n' +
2222 ' {{else}}\n' +
2223 '{{!-- \n' +
2224 ' mult-line\n' +
2225 'comment \n' +
2226 '{{#> component}}\n' +
2227 ' mult-line\n' +
2228 'comment \n' +
2229 ' with spacing\n' +
2230 ' {{/ component}}--}}\n' +
2231 ' {{/if}}\n' +
2232 ' {{else}}\n' +
2233 '{{!-- \n' +
2234 ' mult-line\n' +
2235 'comment \n' +
2236 '{{#> component}}\n' +
2237 ' mult-line\n' +
2238 'comment \n' +
2239 ' with spacing\n' +
2240 ' {{/ component}}--}}\n' +
2241 '{{/if}}',
2242 // -- output --
2243 '{{#if thing}}\n' +
2244 ' {{#if otherthing}}\n' +
2245 ' {{!-- \n' +
2246 ' mult-line\n' +
2247 'comment \n' +
2248 '{{#> component}}\n' +
2249 ' mult-line\n' +
2250 'comment \n' +
2251 ' with spacing\n' +
2252 ' {{/ component}}--}}\n' +
2253 ' {{else}}\n' +
2254 ' {{!-- \n' +
2255 ' mult-line\n' +
2256 'comment \n' +
2257 '{{#> component}}\n' +
2258 ' mult-line\n' +
2259 'comment \n' +
2260 ' with spacing\n' +
2261 ' {{/ component}}--}}\n' +
2262 ' {{/if}}\n' +
2263 '{{else}}\n' +
2264 ' {{!-- \n' +
2265 ' mult-line\n' +
2266 'comment \n' +
2267 '{{#> component}}\n' +
2268 ' mult-line\n' +
2269 'comment \n' +
2270 ' with spacing\n' +
2271 ' {{/ component}}--}}\n' +
2272 '{{/if}}');
2273 test_fragment(
2274 '<div{{somestyle}}></div>',
2275 // -- output --
2276 '<div {{somestyle}}></div>');
2277 test_fragment(
2278 '<div{{#if test}}class="foo"{{/if}}>{{!-- \n' +
2279 ' mult-line\n' +
2280 'comment \n' +
2281 '{{#> component}}\n' +
2282 ' mult-line\n' +
2283 'comment \n' +
2284 ' with spacing\n' +
2285 ' {{/ component}}--}}</div>',
2286 // -- output --
2287 '<div {{#if test}} class="foo" {{/if}}>{{!-- \n' +
2288 ' mult-line\n' +
2289 'comment \n' +
2290 '{{#> component}}\n' +
2291 ' mult-line\n' +
2292 'comment \n' +
2293 ' with spacing\n' +
2294 ' {{/ component}}--}}</div>');
2295 test_fragment(
2296 '<div{{#if thing}}{{somestyle}}class="{{class}}"{{else}}class="{{class2}}"{{/if}}>{{!-- \n' +
2297 ' mult-line\n' +
2298 'comment \n' +
2299 '{{#> component}}\n' +
2300 ' mult-line\n' +
2301 'comment \n' +
2302 ' with spacing\n' +
2303 ' {{/ component}}--}}</div>',
2304 // -- output --
2305 '<div {{#if thing}} {{somestyle}} class="{{class}}" {{else}} class="{{class2}}" {{/if}}>{{!-- \n' +
2306 ' mult-line\n' +
2307 'comment \n' +
2308 '{{#> component}}\n' +
2309 ' mult-line\n' +
2310 'comment \n' +
2311 ' with spacing\n' +
2312 ' {{/ component}}--}}</div>');
2313 test_fragment(
2314 '<span{{#if condition}}class="foo"{{/if}}>{{!-- \n' +
2315 ' mult-line\n' +
2316 'comment \n' +
2317 '{{#> component}}\n' +
2318 ' mult-line\n' +
2319 'comment \n' +
2320 ' with spacing\n' +
2321 ' {{/ component}}--}}</span>',
2322 // -- output --
2323 '<span {{#if condition}} class="foo" {{/if}}>{{!-- \n' +
2324 ' mult-line\n' +
2325 'comment \n' +
2326 '{{#> component}}\n' +
2327 ' mult-line\n' +
2328 'comment \n' +
2329 ' with spacing\n' +
2330 ' {{/ component}}--}}</span>');
2331 test_fragment(
2332 '<div unformatted="{{#if}}{{!-- \n' +
2333 ' mult-line\n' +
2334 'comment \n' +
2335 '{{#> component}}\n' +
2336 ' mult-line\n' +
2337 'comment \n' +
2338 ' with spacing\n' +
2339 ' {{/ component}}--}}{{/if}}">{{!-- \n' +
2340 ' mult-line\n' +
2341 'comment \n' +
2342 '{{#> component}}\n' +
2343 ' mult-line\n' +
2344 'comment \n' +
2345 ' with spacing\n' +
2346 ' {{/ component}}--}}</div>');
2347 test_fragment(
2348 '<div unformatted="{{#if }} {{!-- \n' +
2349 ' mult-line\n' +
2350 'comment \n' +
2351 '{{#> component}}\n' +
2352 ' mult-line\n' +
2353 'comment \n' +
2354 ' with spacing\n' +
2355 ' {{/ component}}--}}{{/if}}">{{!-- \n' +
2356 ' mult-line\n' +
2357 'comment \n' +
2358 '{{#> component}}\n' +
2359 ' mult-line\n' +
2360 'comment \n' +
2361 ' with spacing\n' +
2362 ' {{/ component}}--}}</div>');
2363 test_fragment(
2364 '<div class="{{#if thingIs "value"}}{{!-- \n' +
2365 ' mult-line\n' +
2366 'comment \n' +
2367 '{{#> component}}\n' +
2368 ' mult-line\n' +
2369 'comment \n' +
2370 ' with spacing\n' +
2371 ' {{/ component}}--}}{{/if}}"></div>');
2372 test_fragment(
2373 '<div class="{{#if thingIs \'value\'}}{{!-- \n' +
2374 ' mult-line\n' +
2375 'comment \n' +
2376 '{{#> component}}\n' +
2377 ' mult-line\n' +
2378 'comment \n' +
2379 ' with spacing\n' +
2380 ' {{/ component}}--}}{{/if}}"></div>');
2381 test_fragment(
2382 '<div class=\'{{#if thingIs "value"}}{{!-- \n' +
2383 ' mult-line\n' +
2384 'comment \n' +
2385 '{{#> component}}\n' +
2386 ' mult-line\n' +
2387 'comment \n' +
2388 ' with spacing\n' +
2389 ' {{/ component}}--}}{{/if}}\'></div>');
2390 test_fragment(
2391 '<div class=\'{{#if thingIs \'value\'}}{{!-- \n' +
2392 ' mult-line\n' +
2393 'comment \n' +
2394 '{{#> component}}\n' +
2395 ' mult-line\n' +
2396 'comment \n' +
2397 ' with spacing\n' +
2398 ' {{/ component}}--}}{{/if}}\'></div>');
2399 test_fragment('<span>{{condition < 0 ? "result1" : "result2"}}</span>');
2400 test_fragment('<span>{{condition1 && condition2 && condition3 && condition4 < 0 ? "resForTrue" : "resForFalse"}}</span>');
2401  
2402 // Handlebars Indenting On - (content = "content")
2403 reset_options();
2404 opts.indent_handlebars = true;
2405 opts.wrap_line_length = 80;
2406 test_fragment('{{page-title}}');
2407 test_fragment('{{#if 0}}{{/if}}');
2408 test_fragment('{{#if 0}}content{{/if}}');
2409 test_fragment(
2410 '{{#if 0}}\n' +
2411 '{{/if}}');
2412 test_fragment(
2413 '{{#if words}}{{/if}}',
2414 // -- output --
2415 '{{#if words}}{{/if}}');
2416 test_fragment(
2417 '{{#if words}}content{{/if}}',
2418 // -- output --
2419 '{{#if words}}content{{/if}}');
2420 test_fragment(
2421 '{{#if words}}content{{/if}}',
2422 // -- output --
2423 '{{#if words}}content{{/if}}');
2424 test_fragment(
2425 '{{#if 1}}\n' +
2426 ' <div>\n' +
2427 ' </div>\n' +
2428 '{{/if}}');
2429 test_fragment(
2430 '{{#if 1}}\n' +
2431 '<div>\n' +
2432 '</div>\n' +
2433 '{{/if}}',
2434 // -- output --
2435 '{{#if 1}}\n' +
2436 ' <div>\n' +
2437 ' </div>\n' +
2438 '{{/if}}');
2439 test_fragment(
2440 '<div>\n' +
2441 ' {{#if 1}}\n' +
2442 ' {{/if}}\n' +
2443 '</div>');
2444 test_fragment(
2445 '<div>\n' +
2446 '{{#if 1}}\n' +
2447 '{{/if}}\n' +
2448 '</div>',
2449 // -- output --
2450 '<div>\n' +
2451 ' {{#if 1}}\n' +
2452 ' {{/if}}\n' +
2453 '</div>');
2454 test_fragment(
2455 '{{#if}}\n' +
2456 '{{#each}}\n' +
2457 '{{#if}}\n' +
2458 'content\n' +
2459 '{{/if}}\n' +
2460 '{{#if}}\n' +
2461 'content\n' +
2462 '{{/if}}\n' +
2463 '{{/each}}\n' +
2464 '{{/if}}',
2465 // -- output --
2466 '{{#if}}\n' +
2467 ' {{#each}}\n' +
2468 ' {{#if}}\n' +
2469 ' content\n' +
2470 ' {{/if}}\n' +
2471 ' {{#if}}\n' +
2472 ' content\n' +
2473 ' {{/if}}\n' +
2474 ' {{/each}}\n' +
2475 '{{/if}}');
2476 test_fragment(
2477 '{{#if 1}}\n' +
2478 ' <div>\n' +
2479 ' </div>\n' +
2480 '{{/if}}');
2481 test_fragment(
2482 '{{#if 1}}\n' +
2483 ' content\n' +
2484 ' {{else}}\n' +
2485 ' content\n' +
2486 '{{/if}}',
2487 // -- output --
2488 '{{#if 1}}\n' +
2489 ' content\n' +
2490 '{{else}}\n' +
2491 ' content\n' +
2492 '{{/if}}');
2493 test_fragment(
2494 '{{#if 1}}\n' +
2495 ' {{else}}\n' +
2496 ' {{/if}}',
2497 // -- output --
2498 '{{#if 1}}\n' +
2499 '{{else}}\n' +
2500 '{{/if}}');
2501 test_fragment(
2502 '{{#if thing}}\n' +
2503 '{{#if otherthing}}\n' +
2504 ' content\n' +
2505 ' {{else}}\n' +
2506 'content\n' +
2507 ' {{/if}}\n' +
2508 ' {{else}}\n' +
2509 'content\n' +
2510 '{{/if}}',
2511 // -- output --
2512 '{{#if thing}}\n' +
2513 ' {{#if otherthing}}\n' +
2514 ' content\n' +
2515 ' {{else}}\n' +
2516 ' content\n' +
2517 ' {{/if}}\n' +
2518 '{{else}}\n' +
2519 ' content\n' +
2520 '{{/if}}');
2521 test_fragment(
2522 '<div{{somestyle}}></div>',
2523 // -- output --
2524 '<div {{somestyle}}></div>');
2525 test_fragment(
2526 '<div{{#if test}}class="foo"{{/if}}>content</div>',
2527 // -- output --
2528 '<div {{#if test}} class="foo" {{/if}}>content</div>');
2529 test_fragment(
2530 '<div{{#if thing}}{{somestyle}}class="{{class}}"{{else}}class="{{class2}}"{{/if}}>content</div>',
2531 // -- output --
2532 '<div {{#if thing}} {{somestyle}} class="{{class}}" {{else}} class="{{class2}}" {{/if}}>content</div>');
2533 test_fragment(
2534 '<span{{#if condition}}class="foo"{{/if}}>content</span>',
2535 // -- output --
2536 '<span {{#if condition}} class="foo" {{/if}}>content</span>');
2537 test_fragment('<div unformatted="{{#if}}content{{/if}}">content</div>');
2538 test_fragment('<div unformatted="{{#if }} content{{/if}}">content</div>');
2539 test_fragment('<div class="{{#if thingIs "value"}}content{{/if}}"></div>');
2540 test_fragment('<div class="{{#if thingIs \'value\'}}content{{/if}}"></div>');
2541 test_fragment('<div class=\'{{#if thingIs "value"}}content{{/if}}\'></div>');
2542 test_fragment('<div class=\'{{#if thingIs \'value\'}}content{{/if}}\'></div>');
2543 test_fragment('<span>{{condition < 0 ? "result1" : "result2"}}</span>');
2544 test_fragment('<span>{{condition1 && condition2 && condition3 && condition4 < 0 ? "resForTrue" : "resForFalse"}}</span>');
2545  
2546  
2547 //============================================================
2548 // Handlebars Else tag indenting
2549 reset_options();
2550 opts.indent_handlebars = true;
2551 test_fragment(
2552 '{{#if test}}<div></div>{{else}}<div></div>{{/if}}',
2553 // -- output --
2554 '{{#if test}}\n' +
2555 ' <div></div>\n' +
2556 '{{else}}\n' +
2557 ' <div></div>\n' +
2558 '{{/if}}');
2559 test_fragment('{{#if test}}<span></span>{{else}}<span></span>{{/if}}');
2560  
2561  
2562 //============================================================
2563 // Unclosed html elements
2564 reset_options();
2565 test_fragment(
2566 '<source>\n' +
2567 '<source>');
2568 test_fragment(
2569 '<br>\n' +
2570 '<br>');
2571 test_fragment(
2572 '<input>\n' +
2573 '<input>');
2574 test_fragment(
2575 '<meta>\n' +
2576 '<meta>');
2577 test_fragment(
2578 '<link>\n' +
2579 '<link>');
2580 test_fragment(
2581 '<colgroup>\n' +
2582 ' <col>\n' +
2583 ' <col>\n' +
2584 '</colgroup>');
2585  
2586  
2587 //============================================================
2588 // Unformatted tags
2589 reset_options();
2590 test_fragment(
2591 '<ol>\n' +
2592 ' <li>b<pre>c</pre></li>\n' +
2593 '</ol>',
2594 // -- output --
2595 '<ol>\n' +
2596 ' <li>b\n' +
2597 ' <pre>c</pre>\n' +
2598 ' </li>\n' +
2599 '</ol>');
2600 test_fragment(
2601 '<ol>\n' +
2602 ' <li>b<code>c</code></li>\n' +
2603 '</ol>');
2604 test_fragment(
2605 '<ul>\n' +
2606 ' <li>\n' +
2607 ' <span class="octicon octicon-person"></span>\n' +
2608 ' <a href="/contact/">Kontakt</a>\n' +
2609 ' </li>\n' +
2610 '</ul>');
2611 test_fragment('<div class="searchform"><input type="text" value="" name="s" id="s" /><input type="submit" id="searchsubmit" value="Search" /></div>');
2612 test_fragment('<div class="searchform"><input type="text" value="" name="s" id="s"><input type="submit" id="searchsubmit" value="Search"></div>');
2613 test_fragment(
2614 '<p>\n' +
2615 ' <a href="/test/"><img src="test.jpg" /></a>\n' +
2616 '</p>');
2617 test_fragment(
2618 '<p>\n' +
2619 ' <a href="/test/"><img src="test.jpg" /></a><a href="/test/"><img src="test.jpg" /></a>\n' +
2620 '</p>');
2621 test_fragment(
2622 '<p>\n' +
2623 ' <a href="/test/"><img src="test.jpg" /></a><a href="/test/"><img src="test.jpg" /></a><a href="/test/"><img src="test.jpg" /></a><a href="/test/"><img src="test.jpg" /></a>\n' +
2624 '</p>');
2625 test_fragment(
2626 '<p>\n' +
2627 ' <span>image: <img src="test.jpg" /></span><span>image: <img src="test.jpg" /></span>\n' +
2628 '</p>');
2629 test_fragment(
2630 '<p>\n' +
2631 ' <strong>image: <img src="test.jpg" /></strong><strong>image: <img src="test.jpg" /></strong>\n' +
2632 '</p>');
2633  
2634  
2635 //============================================================
2636 // File starting with comment
2637 reset_options();
2638 test_fragment(
2639 '<!--sample comment -->\n' +
2640 '\n' +
2641 '<html>\n' +
2642 '<body>\n' +
2643 ' <span>a span</span>\n' +
2644 '</body>\n' +
2645 '\n' +
2646 '</html>');
2647  
2648  
2649 //============================================================
2650 // Php formatting
2651 reset_options();
2652 test_fragment(
2653 '<h1 class="content-page-header"><?=$view["name"]; ?></h1>',
2654 // -- output --
2655 '<h1 class="content-page-header">\n' +
2656 ' <?=$view["name"]; ?>\n' +
2657 '</h1>');
2658 test_fragment(
2659 '<?php\n' +
2660 'for($i = 1; $i <= 100; $i++;) {\n' +
2661 ' #count to 100!\n' +
2662 ' echo($i . "</br>");\n' +
2663 '}\n' +
2664 '?>');
2665 test_fragment(
2666 '<?php ?>\n' +
2667 '<!DOCTYPE html>\n' +
2668 '\n' +
2669 '<html>\n' +
2670 '\n' +
2671 '<head></head>\n' +
2672 '\n' +
2673 '<body></body>\n' +
2674 '\n' +
2675 '</html>');
2676  
2677  
2678 //============================================================
2679 // Support simple language specific option inheritance/overriding - (h = " ", c = " ", j = " ")
2680 reset_options();
2681 opts.js = { 'indent_size': 3 };
2682 opts.css = { 'indent_size': 5 };
2683 test_fragment(
2684 '<head>\n' +
2685 ' <script>\n' +
2686 ' if (a == b) {\n' +
2687 ' test();\n' +
2688 ' }\n' +
2689 ' </script>\n' +
2690 ' <style>\n' +
2691 ' .selector {\n' +
2692 ' font-size: 12px;\n' +
2693 ' }\n' +
2694 ' </style>\n' +
2695 '</head>');
2696  
2697 // Support simple language specific option inheritance/overriding - (h = " ", c = " ", j = " ")
2698 reset_options();
2699 opts.html = { 'js': { 'indent_size': 3 }, 'css': { 'indent_size': 5 } };
2700 test_fragment(
2701 '<head>\n' +
2702 ' <script>\n' +
2703 ' if (a == b) {\n' +
2704 ' test();\n' +
2705 ' }\n' +
2706 ' </script>\n' +
2707 ' <style>\n' +
2708 ' .selector {\n' +
2709 ' font-size: 12px;\n' +
2710 ' }\n' +
2711 ' </style>\n' +
2712 '</head>');
2713  
2714 // Support simple language specific option inheritance/overriding - (h = " ", c = " ", j = " ")
2715 reset_options();
2716 opts.indent_size = 9;
2717 opts.html = { 'js': { 'indent_size': 3 }, 'css': { 'indent_size': 5 }, 'indent_size': 2};
2718 opts.js = { 'indent_size': 5 };
2719 opts.css = { 'indent_size': 3 };
2720 test_fragment(
2721 '<head>\n' +
2722 ' <script>\n' +
2723 ' if (a == b) {\n' +
2724 ' test();\n' +
2725 ' }\n' +
2726 ' </script>\n' +
2727 ' <style>\n' +
2728 ' .selector {\n' +
2729 ' font-size: 12px;\n' +
2730 ' }\n' +
2731 ' </style>\n' +
2732 '</head>');
2733  
2734  
2735 //============================================================
2736 // underscore.js formatting
2737 reset_options();
2738 test_fragment(
2739 '<div class="col-sm-9">\n' +
2740 ' <textarea id="notes" class="form-control" rows="3">\n' +
2741 ' <%= notes %>\n' +
2742 ' </textarea>\n' +
2743 '</div>');
2744  
2745  
2746 //============================================================
2747 // Indent with tabs
2748 reset_options();
2749 opts.indent_with_tabs = true;
2750 test_fragment(
2751 '<div>\n' +
2752 '<div>\n' +
2753 '</div>\n' +
2754 '</div>',
2755 // -- output --
2756 '<div>\n' +
2757 '\t<div>\n' +
2758 '\t</div>\n' +
2759 '</div>');
2760  
2761  
2762 //============================================================
2763 // Indent without tabs
2764 reset_options();
2765 opts.indent_with_tabs = false;
2766 test_fragment(
2767 '<div>\n' +
2768 '<div>\n' +
2769 '</div>\n' +
2770 '</div>',
2771 // -- output --
2772 '<div>\n' +
2773 ' <div>\n' +
2774 ' </div>\n' +
2775 '</div>');
2776  
2777  
2778 //============================================================
2779 // Indent body inner html by default
2780 reset_options();
2781 test_fragment(
2782 '<html>\n' +
2783 '<body>\n' +
2784 '<div></div>\n' +
2785 '</body>\n' +
2786 '\n' +
2787 '</html>',
2788 // -- output --
2789 '<html>\n' +
2790 '<body>\n' +
2791 ' <div></div>\n' +
2792 '</body>\n' +
2793 '\n' +
2794 '</html>');
2795  
2796  
2797 //============================================================
2798 // indent_body_inner_html set to false prevents indent of body inner html
2799 reset_options();
2800 opts.indent_body_inner_html = false;
2801 test_fragment(
2802 '<html>\n' +
2803 '<body>\n' +
2804 '<div></div>\n' +
2805 '</body>\n' +
2806 '\n' +
2807 '</html>');
2808  
2809  
2810 //============================================================
2811 // Indent head inner html by default
2812 reset_options();
2813 test_fragment(
2814 '<html>\n' +
2815 '\n' +
2816 '<head>\n' +
2817 '<meta>\n' +
2818 '</head>\n' +
2819 '\n' +
2820 '</html>',
2821 // -- output --
2822 '<html>\n' +
2823 '\n' +
2824 '<head>\n' +
2825 ' <meta>\n' +
2826 '</head>\n' +
2827 '\n' +
2828 '</html>');
2829  
2830  
2831 //============================================================
2832 // indent_head_inner_html set to false prevents indent of head inner html
2833 reset_options();
2834 opts.indent_head_inner_html = false;
2835 test_fragment(
2836 '<html>\n' +
2837 '\n' +
2838 '<head>\n' +
2839 '<meta>\n' +
2840 '</head>\n' +
2841 '\n' +
2842 '</html>');
2843  
2844  
2845 //============================================================
2846 // content_unformatted to prevent formatting content
2847 reset_options();
2848 opts.content_unformatted = ['script', 'style', 'p', 'span', 'br'];
2849 test_fragment(
2850 '<html><body><h1>A</h1><script>if(1){f();}</script><style>.a{display:none;}</style></body></html>',
2851 // -- output --
2852 '<html>\n' +
2853 '<body>\n' +
2854 ' <h1>A</h1>\n' +
2855 ' <script>if(1){f();}</script>\n' +
2856 ' <style>.a{display:none;}</style>\n' +
2857 '</body>\n' +
2858 '\n' +
2859 '</html>');
2860 test_fragment(
2861 '<div><p>Beautify me</p></div><p><p>But not me</p></p>',
2862 // -- output --
2863 '<div>\n' +
2864 ' <p>Beautify me</p>\n' +
2865 '</div>\n' +
2866 '<p><p>But not me</p></p>');
2867 test_fragment(
2868 '<div><p\n' +
2869 ' class="beauty-me"\n' +
2870 '>Beautify me</p></div><p><p\n' +
2871 ' class="iamalreadybeauty"\n' +
2872 '>But not me</p></p>',
2873 // -- output --
2874 '<div>\n' +
2875 ' <p class="beauty-me">Beautify me</p>\n' +
2876 '</div>\n' +
2877 '<p><p\n' +
2878 ' class="iamalreadybeauty"\n' +
2879 '>But not me</p></p>');
2880 test_fragment('<div><span>blabla<div>something here</div></span></div>');
2881 test_fragment('<div><br /></div>');
2882 test_fragment(
2883 '<div><pre>var a=1;\n' +
2884 'var b=a;</pre></div>',
2885 // -- output --
2886 '<div>\n' +
2887 ' <pre>var a=1; var b=a;</pre>\n' +
2888 '</div>');
2889 test_fragment(
2890 '<div><pre>\n' +
2891 'var a=1;\n' +
2892 'var b=a;\n' +
2893 '</pre></div>',
2894 // -- output --
2895 '<div>\n' +
2896 ' <pre>\n' +
2897 ' var a=1; var b=a;\n' +
2898 ' </pre>\n' +
2899 '</div>');
2900  
2901  
2902 //============================================================
2903 // default content_unformatted
2904 reset_options();
2905 test_fragment(
2906 '<html><body><h1>A</h1><script>if(1){f();}</script><style>.a{display:none;}</style></body></html>',
2907 // -- output --
2908 '<html>\n' +
2909 '<body>\n' +
2910 ' <h1>A</h1>\n' +
2911 ' <script>\n' +
2912 ' if (1) {\n' +
2913 ' f();\n' +
2914 ' }\n' +
2915 ' </script>\n' +
2916 ' <style>\n' +
2917 ' .a {\n' +
2918 ' display: none;\n' +
2919 ' }\n' +
2920 ' </style>\n' +
2921 '</body>\n' +
2922 '\n' +
2923 '</html>');
2924 test_fragment(
2925 '<div><p>Beautify me</p></div><p><p>But not me</p></p>',
2926 // -- output --
2927 '<div>\n' +
2928 ' <p>Beautify me</p>\n' +
2929 '</div>\n' +
2930 '<p>\n' +
2931 ' <p>But not me</p>\n' +
2932 '</p>');
2933 test_fragment(
2934 '<div><p\n' +
2935 ' class="beauty-me"\n' +
2936 '>Beautify me</p></div><p><p\n' +
2937 ' class="iamalreadybeauty"\n' +
2938 '>But not me</p></p>',
2939 // -- output --
2940 '<div>\n' +
2941 ' <p class="beauty-me">Beautify me</p>\n' +
2942 '</div>\n' +
2943 '<p>\n' +
2944 ' <p class="iamalreadybeauty">But not me</p>\n' +
2945 '</p>');
2946 test_fragment('<div><span>blabla<div>something here</div></span></div>');
2947 test_fragment('<div><br /></div>');
2948 test_fragment(
2949 '<div><pre>var a=1;\n' +
2950 'var b=a;</pre></div>',
2951 // -- output --
2952 '<div>\n' +
2953 ' <pre>var a=1;\n' +
2954 'var b=a;</pre>\n' +
2955 '</div>');
2956 test_fragment(
2957 '<div><pre>\n' +
2958 'var a=1;\n' +
2959 'var b=a;\n' +
2960 '</pre></div>',
2961 // -- output --
2962 '<div>\n' +
2963 ' <pre>\n' +
2964 'var a=1;\n' +
2965 'var b=a;\n' +
2966 '</pre>\n' +
2967 '</div>');
2968  
2969  
2970 //============================================================
2971 // New Test Suite
2972 reset_options();
2973  
2974  
2975 }
2976  
2977 function beautifier_unconverted_tests()
2978 {
2979 sanitytest = test_obj;
2980  
2981 reset_options();
2982 //============================================================
2983 opts.end_with_newline = true;
2984 test_fragment('', '\n');
2985 test_fragment('<div></div>\n');
2986 test_fragment('<div></div>\n\n\n', '<div></div>\n');
2987 test_fragment('<head>\n' +
2988 ' <script>\n' +
2989 ' mocha.setup("bdd");\n' +
2990 '\n' +
2991 ' </script>\n' +
2992 '</head>\n');
2993  
2994  
2995 opts.end_with_newline = false;
2996 // error cases need love too
2997 bth('<img title="Bad food!" src="foo.jpg" alt="Evil" ">');
2998 bth("<!-- don't blow up if a comment is not complete"); // -->
2999  
3000 test_fragment(
3001 '<head>\n' +
3002 ' <script>\n' +
3003 ' mocha.setup("bdd");\n' +
3004 ' </script>\n' +
3005 '</head>');
3006  
3007 test_fragment('<div></div>\n', '<div></div>');
3008 bth('<div></div>');
3009 bth('<div>content</div>');
3010 bth('<div><div></div></div>',
3011 '<div>\n' +
3012 ' <div></div>\n' +
3013 '</div>');
3014 bth('<div><div>content</div></div>',
3015 '<div>\n' +
3016 ' <div>content</div>\n' +
3017 '</div>');
3018 bth('<div>\n' +
3019 ' <span>content</span>\n' +
3020 '</div>');
3021 bth('<div>\n' +
3022 '</div>');
3023 bth('<div>\n' +
3024 ' content\n' +
3025 '</div>');
3026 bth('<div>\n' +
3027 ' </div>',
3028 '<div>\n' +
3029 '</div>');
3030 bth(' <div>\n' +
3031 ' </div>',
3032 '<div>\n' +
3033 '</div>');
3034 bth('<div>\n' +
3035 '</div>\n' +
3036 ' <div>\n' +
3037 ' </div>',
3038 '<div>\n' +
3039 '</div>\n' +
3040 '<div>\n' +
3041 '</div>');
3042 bth(' <div>\n' +
3043 '</div>',
3044 '<div>\n' +
3045 '</div>');
3046 bth('<div >content</div>',
3047 '<div>content</div>');
3048 bth('<div thinger="preserve space here" ></div >',
3049 '<div thinger="preserve space here"></div>');
3050 bth('content\n' +
3051 ' <div>\n' +
3052 ' </div>\n' +
3053 'content',
3054 'content\n' +
3055 '<div>\n' +
3056 '</div>\n' +
3057 'content');
3058 bth('<li>\n' +
3059 ' <div>\n' +
3060 ' </div>\n' +
3061 '</li>');
3062 bth('<li>\n' +
3063 '<div>\n' +
3064 '</div>\n' +
3065 '</li>',
3066 '<li>\n' +
3067 ' <div>\n' +
3068 ' </div>\n' +
3069 '</li>');
3070 bth('<li>\n' +
3071 ' content\n' +
3072 '</li>\n' +
3073 '<li>\n' +
3074 ' content\n' +
3075 '</li>');
3076  
3077 bth('<img>content');
3078 bth('<img> content');
3079 bth('<img> content', '<img> content');
3080  
3081 bth('<img><img>content');
3082 bth('<img> <img>content');
3083 bth('<img> <img>content', '<img> <img>content');
3084  
3085 bth('<img><b>content</b>');
3086 bth('<img> <b>content</b>');
3087 bth('<img> <b>content</b>', '<img> <b>content</b>');
3088  
3089 bth('<div>content<img>content</div>');
3090 bth('<div> content <img> content</div>');
3091 bth('<div> content <img> content </div>',
3092 '<div> content <img> content </div>');
3093 bth('Text <a href="#">Link</a> Text');
3094  
3095 var unformatted = opts.unformatted;
3096 opts.unformatted = ['script', 'style'];
3097 bth('<script id="javascriptTemplate" type="text/x-kendo-template">\n' +
3098 ' <ul>\n' +
3099 ' # for (var i = 0; i < data.length; i++) { #\n' +
3100 ' <li>#= data[i] #</li>\n' +
3101 ' # } #\n' +
3102 ' </ul>\n' +
3103 '</script>');
3104 bth('<style>\n' +
3105 ' body {background-color:lightgrey}\n' +
3106 ' h1 {color:blue}\n' +
3107 '</style>');
3108 opts.unformatted = unformatted;
3109  
3110 unformatted = opts.unformatted;
3111 opts.unformatted = ['custom-element'];
3112 test_fragment('<div>should <custom-element>not</custom-element>' +
3113 ' insert newlines</div>',
3114 '<div>should <custom-element>not</custom-element>' +
3115 ' insert newlines</div>');
3116 opts.unformatted = unformatted;
3117  
3118 // Tests that don't pass, but probably should.
3119 // bth('<div><span>content</span></div>');
3120  
3121 // Handlebars tests
3122 // Without the indent option on, handlebars are treated as content.
3123  
3124 opts.wrap_line_length = 0;
3125 //...---------1---------2---------3---------4---------5---------6---------7
3126 //...1234567890123456789012345678901234567890123456789012345678901234567890
3127 bth('<div>Some text that should not wrap at all.</div>',
3128 /* expected */
3129 '<div>Some text that should not wrap at all.</div>');
3130  
3131 // A value of 0 means no max line length, and should not wrap.
3132 //...---------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
3133 //...12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
3134 bth('<div>Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all.</div>',
3135 /* expected */
3136 '<div>Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all.</div>');
3137  
3138 opts.wrap_line_length = "0";
3139 //...---------1---------2---------3---------4---------5---------6---------7
3140 //...1234567890123456789012345678901234567890123456789012345678901234567890
3141 bth('<div>Some text that should not wrap at all.</div>',
3142 /* expected */
3143 '<div>Some text that should not wrap at all.</div>');
3144  
3145 // A value of "0" means no max line length, and should not wrap
3146 //...---------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
3147 //...12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
3148 bth('<div>Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all.</div>',
3149 /* expected */
3150 '<div>Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all. Some text that should not wrap at all.</div>');
3151  
3152 //BUGBUG: This should wrap before 40 not after.
3153 opts.wrap_line_length = 40;
3154 //...---------1---------2---------3---------4---------5---------6---------7
3155 //...1234567890123456789012345678901234567890123456789012345678901234567890
3156 bth('<div>Some test text that should wrap_inside_this section here.</div>',
3157 /* expected */
3158 '<div>Some test text that should wrap_inside_this\n' +
3159 ' section here.</div>');
3160  
3161 opts.wrap_line_length = "40";
3162 //...---------1---------2---------3---------4---------5---------6---------7
3163 //...1234567890123456789012345678901234567890123456789012345678901234567890
3164 bth('<div>Some test text that should wrap_inside_this section here.</div>',
3165 /* expected */
3166 '<div>Some test text that should wrap_inside_this\n' +
3167 ' section here.</div>');
3168  
3169 opts.indent_size = 1;
3170 opts.indent_char = '\t';
3171 opts.preserve_newlines = false;
3172 bth('<div>\n\tfoo\n</div>', '<div> foo </div>');
3173  
3174 opts.preserve_newlines = true;
3175 bth('<div>\n\tfoo\n</div>');
3176  
3177  
3178  
3179 // test preserve_newlines and max_preserve_newlines
3180 opts.preserve_newlines = false;
3181 bth('<div>Should not</div>\n\n\n' +
3182 '<div>preserve newlines</div>',
3183 '<div>Should not</div>\n' +
3184 '<div>preserve newlines</div>');
3185  
3186 opts.preserve_newlines = true;
3187 opts.max_preserve_newlines = 0;
3188 bth('<div>Should</div>\n\n\n' +
3189 '<div>preserve zero newlines</div>',
3190 '<div>Should</div>\n' +
3191 '<div>preserve zero newlines</div>');
3192  
3193 opts.max_preserve_newlines = 1;
3194 bth('<div>Should</div>\n\n\n' +
3195 '<div>preserve one newline</div>',
3196 '<div>Should</div>\n\n' +
3197 '<div>preserve one newline</div>');
3198  
3199 opts.max_preserve_newlines = null;
3200 bth('<div>Should</div>\n\n\n' +
3201 '<div>preserve one newline</div>',
3202 '<div>Should</div>\n\n\n' +
3203 '<div>preserve one newline</div>');
3204 }
3205  
3206 beautifier_tests();
3207 beautifier_unconverted_tests();
3208 }
3209  
3210 if (typeof exports !== "undefined") {
3211 exports.run_html_tests = run_html_tests;
3212 }