solution to partials not seperated by spaces

This commit is contained in:
avento 2022-04-15 13:14:34 -04:00
parent 4df0273a74
commit 63c9ffa11c
2 changed files with 60 additions and 0 deletions

View File

@ -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();

View File

@ -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"
}]