mirror of
https://github.com/beautifier/js-beautify.git
synced 2024-11-23 12:49:40 +00:00
solution to partials not seperated by spaces
This commit is contained in:
parent
4df0273a74
commit
63c9ffa11c
@ -608,11 +608,17 @@ var TagOpenParserToken = function(parent, raw_token) {
|
||||
this.tag_check = tag_check_match ? tag_check_match[1] : '';
|
||||
} else {
|
||||
tag_check_match = raw_token.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/);
|
||||
|
||||
this.tag_check = tag_check_match ? tag_check_match[1] : '';
|
||||
|
||||
// handle "{{#> myPartial}}" or "{{~#> myPartial}}"
|
||||
if ((raw_token.text === '{{#>' || raw_token.text === '{{~#>') && this.tag_check === '>' && raw_token.next !== null) {
|
||||
this.tag_check = raw_token.next.text.split(' ')[0];
|
||||
} else {
|
||||
// handle "{{#>myPartial}}" or "{{~#>myPartial}}"
|
||||
if (raw_token.text.slice(0, 4) === ('{{#>') || raw_token.text.slice(0, 5) === ('{{~#>') && this.tag_check[0] === '>') {
|
||||
this.tag_check = raw_token.text.split('>')[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
this.tag_check = this.tag_check.toLowerCase();
|
||||
|
@ -3591,6 +3591,60 @@ exports.test_data = {
|
||||
'{{/if}}'
|
||||
]
|
||||
}]
|
||||
}, {
|
||||
name: "Handle Partials Not Seperated by Spaces",
|
||||
description: "Handles partials that do not have a space before the tag",
|
||||
template: "^^^ $$$",
|
||||
options: [
|
||||
{ name: "nospace_partials", value: "true" }
|
||||
],
|
||||
tests: [{
|
||||
input: [
|
||||
'{{#>row}}',
|
||||
' {{#>column}}',
|
||||
' <span>content</span>',
|
||||
' {{/column}}',
|
||||
' {{/row}}'
|
||||
],
|
||||
output: [
|
||||
'{{#>row}}',
|
||||
' {{#>column}}',
|
||||
' <span>content</span>',
|
||||
' {{/column}}',
|
||||
'{{/row}}'
|
||||
]
|
||||
}, {
|
||||
input: [
|
||||
'{{~#>row}}',
|
||||
'{{#>column}}',
|
||||
'<p>content</p>',
|
||||
'{{/column}}',
|
||||
'{{/row}}'
|
||||
],
|
||||
output: [
|
||||
'{{~#>row}}',
|
||||
' {{#>column}}',
|
||||
' <p>content</p>',
|
||||
' {{/column}}',
|
||||
'{{/row}}'
|
||||
]
|
||||
}, {
|
||||
unchanged: [
|
||||
'{{#>row}}',
|
||||
' {{#>column}}',
|
||||
' <span>content</span>',
|
||||
' {{/column}}',
|
||||
'{{/row}}'
|
||||
]
|
||||
}, {
|
||||
unchanged: [
|
||||
'{{#> row}}',
|
||||
' {{#> column}}',
|
||||
' <span>content</span>',
|
||||
' {{/column}}',
|
||||
'{{/row}}'
|
||||
]
|
||||
}]
|
||||
}, {
|
||||
name: "New Test Suite"
|
||||
}]
|
||||
|
Loading…
Reference in New Issue
Block a user