diff --git a/js/lib/beautify-html.js b/js/lib/beautify-html.js
index eaa047583..c21b813e7 100644
--- a/js/lib/beautify-html.js
+++ b/js/lib/beautify-html.js
@@ -595,9 +595,14 @@
} else if (comment.indexOf('';
matched = true;
- } else if (comment.indexOf('{{!') === 0) { // {{! handlebars comment
- delimiter = '}}';
+ } else if (comment.indexOf('{{!--') === 0) { // {{!-- handlebars comment
+ delimiter = '--}}';
matched = true;
+ } else if (comment.indexOf('{{!') === 0) { // {{! handlebars comment
+ if (comment.length === 5 && comment.indexOf('{{!--') === -1) {
+ delimiter = '}}';
+ matched = true;
+ }
} else if (comment.indexOf('') === 0) { // {{! handlebars comment
delimiter = '?>';
matched = true;
diff --git a/js/test/generated/beautify-html-tests.js b/js/test/generated/beautify-html-tests.js
index a31e478b9..082cd1f30 100644
--- a/js/test/generated/beautify-html-tests.js
+++ b/js/test/generated/beautify-html-tests.js
@@ -464,6 +464,61 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be
test_fragment('
');
test_fragment('');
+ // Handlebars Indenting On - (content = "{{!-- comment--}}")
+ opts.indent_handlebars = true;
+ test_fragment('{{page-title}}');
+ test_fragment('{{#if 0}}{{/if}}');
+ test_fragment('{{#if 0}}{{!-- comment--}}{{/if}}');
+ test_fragment('{{#if 0}}\n{{/if}}');
+ test_fragment(
+ '{{#if words}}{{/if}}',
+ '{{#if words}}{{/if}}');
+ test_fragment(
+ '{{#if words}}{{!-- comment--}}{{/if}}',
+ '{{#if words}}{{!-- comment--}}{{/if}}');
+ test_fragment(
+ '{{#if words}}{{!-- comment--}}{{/if}}',
+ '{{#if words}}{{!-- comment--}}{{/if}}');
+ test_fragment('{{#if 1}}\n \n
\n{{/if}}');
+ test_fragment(
+ '{{#if 1}}\n\n
\n{{/if}}',
+ '{{#if 1}}\n \n
\n{{/if}}');
+ test_fragment('\n {{#if 1}}\n {{/if}}\n
');
+ test_fragment(
+ '\n{{#if 1}}\n{{/if}}\n
',
+ '\n {{#if 1}}\n {{/if}}\n
');
+ test_fragment(
+ '{{#if}}\n{{#each}}\n{{#if}}\n{{!-- comment--}}\n{{/if}}\n{{#if}}\n{{!-- comment--}}\n{{/if}}\n{{/each}}\n{{/if}}',
+ '{{#if}}\n {{#each}}\n {{#if}}\n {{!-- comment--}}\n {{/if}}\n {{#if}}\n {{!-- comment--}}\n {{/if}}\n {{/each}}\n{{/if}}');
+ test_fragment('{{#if 1}}\n \n
\n{{/if}}');
+ test_fragment(
+ '{{#if 1}}\n {{!-- comment--}}\n {{else}}\n {{!-- comment--}}\n{{/if}}',
+ '{{#if 1}}\n {{!-- comment--}}\n{{else}}\n {{!-- comment--}}\n{{/if}}');
+ test_fragment(
+ '{{#if 1}}\n {{else}}\n {{/if}}',
+ '{{#if 1}}\n{{else}}\n{{/if}}');
+ test_fragment(
+ '{{#if thing}}\n{{#if otherthing}}\n {{!-- comment--}}\n {{else}}\n{{!-- comment--}}\n {{/if}}\n {{else}}\n{{!-- comment--}}\n{{/if}}',
+ '{{#if thing}}\n {{#if otherthing}}\n {{!-- comment--}}\n {{else}}\n {{!-- comment--}}\n {{/if}}\n{{else}}\n {{!-- comment--}}\n{{/if}}');
+ test_fragment(
+ '',
+ '');
+ test_fragment(
+ '{{!-- comment--}}
',
+ '{{!-- comment--}}
');
+ test_fragment(
+ '{{!-- comment--}}
',
+ '{{!-- comment--}}
');
+ test_fragment(
+ '{{!-- comment--}}',
+ '{{!-- comment--}}');
+ test_fragment('{{!-- comment--}}
');
+ test_fragment('{{!-- comment--}}
');
+ test_fragment('');
+ test_fragment('');
+ test_fragment('');
+ test_fragment('');
+
// Handlebars Indenting On - (content = "{pre{{field1}} {{field2}} {{field3}}post")
opts.indent_handlebars = true;
test_fragment('{{page-title}}');
@@ -574,6 +629,116 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be
test_fragment('');
test_fragment('');
+ // Handlebars Indenting On - (content = "{{!-- \n mult-line\ncomment \n with spacing\n--}}")
+ opts.indent_handlebars = true;
+ test_fragment('{{page-title}}');
+ test_fragment('{{#if 0}}{{/if}}');
+ test_fragment('{{#if 0}}{{!-- \n mult-line\ncomment \n with spacing\n--}}{{/if}}');
+ test_fragment('{{#if 0}}\n{{/if}}');
+ test_fragment(
+ '{{#if words}}{{/if}}',
+ '{{#if words}}{{/if}}');
+ test_fragment(
+ '{{#if words}}{{!-- \n mult-line\ncomment \n with spacing\n--}}{{/if}}',
+ '{{#if words}}{{!-- \n mult-line\ncomment \n with spacing\n--}}{{/if}}');
+ test_fragment(
+ '{{#if words}}{{!-- \n mult-line\ncomment \n with spacing\n--}}{{/if}}',
+ '{{#if words}}{{!-- \n mult-line\ncomment \n with spacing\n--}}{{/if}}');
+ test_fragment('{{#if 1}}\n \n
\n{{/if}}');
+ test_fragment(
+ '{{#if 1}}\n\n
\n{{/if}}',
+ '{{#if 1}}\n \n
\n{{/if}}');
+ test_fragment('\n {{#if 1}}\n {{/if}}\n
');
+ test_fragment(
+ '\n{{#if 1}}\n{{/if}}\n
',
+ '\n {{#if 1}}\n {{/if}}\n
');
+ test_fragment(
+ '{{#if}}\n{{#each}}\n{{#if}}\n{{!-- \n mult-line\ncomment \n with spacing\n--}}\n{{/if}}\n{{#if}}\n{{!-- \n mult-line\ncomment \n with spacing\n--}}\n{{/if}}\n{{/each}}\n{{/if}}',
+ '{{#if}}\n {{#each}}\n {{#if}}\n {{!-- \n mult-line\ncomment \n with spacing\n--}}\n {{/if}}\n {{#if}}\n {{!-- \n mult-line\ncomment \n with spacing\n--}}\n {{/if}}\n {{/each}}\n{{/if}}');
+ test_fragment('{{#if 1}}\n \n
\n{{/if}}');
+ test_fragment(
+ '{{#if 1}}\n {{!-- \n mult-line\ncomment \n with spacing\n--}}\n {{else}}\n {{!-- \n mult-line\ncomment \n with spacing\n--}}\n{{/if}}',
+ '{{#if 1}}\n {{!-- \n mult-line\ncomment \n with spacing\n--}}\n{{else}}\n {{!-- \n mult-line\ncomment \n with spacing\n--}}\n{{/if}}');
+ test_fragment(
+ '{{#if 1}}\n {{else}}\n {{/if}}',
+ '{{#if 1}}\n{{else}}\n{{/if}}');
+ test_fragment(
+ '{{#if thing}}\n{{#if otherthing}}\n {{!-- \n mult-line\ncomment \n with spacing\n--}}\n {{else}}\n{{!-- \n mult-line\ncomment \n with spacing\n--}}\n {{/if}}\n {{else}}\n{{!-- \n mult-line\ncomment \n with spacing\n--}}\n{{/if}}',
+ '{{#if thing}}\n {{#if otherthing}}\n {{!-- \n mult-line\ncomment \n with spacing\n--}}\n {{else}}\n {{!-- \n mult-line\ncomment \n with spacing\n--}}\n {{/if}}\n{{else}}\n {{!-- \n mult-line\ncomment \n with spacing\n--}}\n{{/if}}');
+ test_fragment(
+ '',
+ '');
+ test_fragment(
+ '{{!-- \n mult-line\ncomment \n with spacing\n--}}
',
+ '{{!-- \n mult-line\ncomment \n with spacing\n--}}
');
+ test_fragment(
+ '{{!-- \n mult-line\ncomment \n with spacing\n--}}
',
+ '{{!-- \n mult-line\ncomment \n with spacing\n--}}
');
+ test_fragment(
+ '{{!-- \n mult-line\ncomment \n with spacing\n--}}',
+ '{{!-- \n mult-line\ncomment \n with spacing\n--}}');
+ test_fragment('{{!-- \n mult-line\ncomment \n with spacing\n--}}
');
+ test_fragment('{{!-- \n mult-line\ncomment \n with spacing\n--}}
');
+ test_fragment('');
+ test_fragment('');
+ test_fragment('');
+ test_fragment('');
+
+ // Handlebars Indenting On - (content = "{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}")
+ opts.indent_handlebars = true;
+ test_fragment('{{page-title}}');
+ test_fragment('{{#if 0}}{{/if}}');
+ test_fragment('{{#if 0}}{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}{{/if}}');
+ test_fragment('{{#if 0}}\n{{/if}}');
+ test_fragment(
+ '{{#if words}}{{/if}}',
+ '{{#if words}}{{/if}}');
+ test_fragment(
+ '{{#if words}}{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}{{/if}}',
+ '{{#if words}}{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}{{/if}}');
+ test_fragment(
+ '{{#if words}}{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}{{/if}}',
+ '{{#if words}}{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}{{/if}}');
+ test_fragment('{{#if 1}}\n \n
\n{{/if}}');
+ test_fragment(
+ '{{#if 1}}\n\n
\n{{/if}}',
+ '{{#if 1}}\n \n
\n{{/if}}');
+ test_fragment('\n {{#if 1}}\n {{/if}}\n
');
+ test_fragment(
+ '\n{{#if 1}}\n{{/if}}\n
',
+ '\n {{#if 1}}\n {{/if}}\n
');
+ test_fragment(
+ '{{#if}}\n{{#each}}\n{{#if}}\n{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n{{/if}}\n{{#if}}\n{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n{{/if}}\n{{/each}}\n{{/if}}',
+ '{{#if}}\n {{#each}}\n {{#if}}\n {{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n {{/if}}\n {{#if}}\n {{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n {{/if}}\n {{/each}}\n{{/if}}');
+ test_fragment('{{#if 1}}\n \n
\n{{/if}}');
+ test_fragment(
+ '{{#if 1}}\n {{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n {{else}}\n {{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n{{/if}}',
+ '{{#if 1}}\n {{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n{{else}}\n {{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n{{/if}}');
+ test_fragment(
+ '{{#if 1}}\n {{else}}\n {{/if}}',
+ '{{#if 1}}\n{{else}}\n{{/if}}');
+ test_fragment(
+ '{{#if thing}}\n{{#if otherthing}}\n {{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n {{else}}\n{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n {{/if}}\n {{else}}\n{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n{{/if}}',
+ '{{#if thing}}\n {{#if otherthing}}\n {{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n {{else}}\n {{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n {{/if}}\n{{else}}\n {{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}\n{{/if}}');
+ test_fragment(
+ '',
+ '');
+ test_fragment(
+ '{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}
',
+ '{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}
');
+ test_fragment(
+ '{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}
',
+ '{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}
');
+ test_fragment(
+ '{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}',
+ '{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}');
+ test_fragment('{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}
');
+ test_fragment('{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}
');
+ test_fragment('');
+ test_fragment('');
+ test_fragment('');
+ test_fragment('');
+
reset_options();
//============================================================
diff --git a/test/data/html/tests.js b/test/data/html/tests.js
index ea2114c7a..7238d0dc9 100644
--- a/test/data/html/tests.js
+++ b/test/data/html/tests.js
@@ -389,6 +389,11 @@ exports.test_data = {
{ name: "indent_handlebars", value: "true" }
],
content: '{{! comment}}'
+ }, {
+ options: [
+ { name: "indent_handlebars", value: "true" }
+ ],
+ content: '{{!-- comment--}}'
}, {
options: [
{ name: "indent_handlebars", value: "true" }
@@ -399,6 +404,16 @@ exports.test_data = {
{ name: "indent_handlebars", value: "true" }
],
content: '{{! \\n mult-line\\ncomment \\n with spacing\\n}}'
+ }, {
+ options: [
+ { name: "indent_handlebars", value: "true" }
+ ],
+ content: '{{!-- \\n mult-line\\ncomment \\n with spacing\\n--}}'
+ }, {
+ options: [
+ { name: "indent_handlebars", value: "true" }
+ ],
+ content: '{{!-- \\n mult-line\\ncomment \\n{{#> component}}\\n mult-line\\ncomment \\n with spacing\\n {{/ component}}--}}'
}],
tests: [
{ fragment: true, unchanged: '{{page-title}}' },