Skip to content

Commit

Permalink
Merge pull request #1624 from e2tha-e/issue-1623-indent-inverted-sect…
Browse files Browse the repository at this point in the history
…ions

Fix indenting of Handlebars/Mustache inverted sections
  • Loading branch information
bitwiseman authored Jan 30, 2019
2 parents bf66ca1 + 33db5b5 commit 3d3bbf2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion js/src/html/beautifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ var TagOpenParserToken = function(parent, raw_token) {
tag_check_match = raw_token.text.match(/^<([^\s>]*)/);
this.tag_check = tag_check_match ? tag_check_match[1] : '';
} else {
tag_check_match = raw_token.text.match(/^{{\#?([^\s}]+)/);
tag_check_match = raw_token.text.match(/^{{[#\^]?([^\s}]+)/);
this.tag_check = tag_check_match ? tag_check_match[1] : '';
}
this.tag_check = this.tag_check.toLowerCase();
Expand Down
10 changes: 8 additions & 2 deletions js/test/generated/beautify-html-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6029,9 +6029,9 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be


//============================================================
// Handlebars Else If and Each tag indenting
// Handlebars Else If, Each, and Inverted Section tag indenting
reset_options();
set_name('Handlebars Else If and Each tag indenting');
set_name('Handlebars Else If, Each, and Inverted Section tag indenting');
opts.indent_handlebars = true;
bth(
'{{#if test}}<div></div>{{else}}<div></div>{{/if}}',
Expand Down Expand Up @@ -6067,6 +6067,12 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be
'{{else}}\n' +
' <p>Unfortunately no clinics found.</p>\n' +
'{{/each}}');

// Issue #1623 - Fix indentation of `^` inverted section tags in Handlebars/Mustache code
bth(
'{{^inverted-condition}}\n' +
' <p>Unfortunately this condition is false.</p>\n' +
'{{/inverted-condition}}');


//============================================================
Expand Down
13 changes: 11 additions & 2 deletions test/data/html/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1349,8 +1349,8 @@ exports.test_data = {
}
]
}, {
name: "Handlebars Else If and Each tag indenting",
description: "Handlebar Else If and Each Handling tags should be newlined after formatted tags",
name: "Handlebars Else If, Each, and Inverted Section tag indenting",
description: "Handlebar Else If, Each, and Inverted Section handling tags should be newlined after formatted tags",
template: "^^^ $$$",
options: [
{ name: "indent_handlebars", value: "true" }
Expand Down Expand Up @@ -1392,6 +1392,15 @@ exports.test_data = {
' <p>Unfortunately no clinics found.</p>',
'{{/each}}'
]
},
// Inverted section handling.
{
comment: "Issue #1623 - Fix indentation of `^` inverted section tags in Handlebars/Mustache code",
unchanged: [
'{{^inverted-condition}}',
' <p>Unfortunately this condition is false.</p>',
'{{/inverted-condition}}'
]
}
]
}, {
Expand Down

0 comments on commit 3d3bbf2

Please sign in to comment.