mirror of
https://github.com/Hopiu/djLint.git
synced 2026-03-16 21:40:24 +00:00
fix(handlebars each): fixed bug in handlebars tags w/ trailing pipe
closes #529
This commit is contained in:
parent
749ec05a03
commit
9d42baf626
5 changed files with 20 additions and 9 deletions
|
|
@ -85,7 +85,10 @@ const widont = (string) => {
|
|||
};
|
||||
|
||||
module.exports = function (eleventyConfig) {
|
||||
eleventyConfig.addGlobalData("djlint_version", require('../package.json').version);
|
||||
eleventyConfig.addGlobalData(
|
||||
'djlint_version',
|
||||
require('../package.json').version,
|
||||
);
|
||||
eleventyConfig.setUseGitIgnore(false);
|
||||
eleventyConfig.addFilter('widont', widont);
|
||||
eleventyConfig.addWatchTarget('./src/static/');
|
||||
|
|
|
|||
|
|
@ -33,4 +33,3 @@ profile="{{ tool }}"
|
|||
## Real Life Examples!
|
||||
|
||||
- [apostrophe](https://github.com/apostrophecms/apostrophe) source code [reformatted](https://github.com/Riverside-Healthcare/djLint/compare/apostrophe-source...Riverside-Healthcare:djLint:apostrophe-djlint)
|
||||
|
||||
|
|
|
|||
|
|
@ -89,11 +89,11 @@ if (typeof Worker !== 'undefined') {
|
|||
}
|
||||
if ((type == 'error' || type == 'html') && id == session_id) {
|
||||
setOutput(message);
|
||||
} else if (type == "status") {
|
||||
console.log(message)
|
||||
} else if (type == "version") {
|
||||
} else if (type == 'status') {
|
||||
console.log(message);
|
||||
} else if (type == 'version') {
|
||||
document.getElementById('djlint-version').textContent = message;
|
||||
}else {
|
||||
} else {
|
||||
console.log(event.data);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ def expand_html(html: str, config: Config) -> str:
|
|||
break_char
|
||||
+ r"\K((?:{%|{{\#)[ ]*?(?:"
|
||||
+ config.break_template_tags
|
||||
+ ")[^}]+?[%|}]})",
|
||||
+ ")[^}]+?[%}]})",
|
||||
flags=re.IGNORECASE | re.MULTILINE | re.VERBOSE,
|
||||
),
|
||||
partial(should_i_move_template_tag, "\n%s"),
|
||||
|
|
@ -101,7 +101,7 @@ def expand_html(html: str, config: Config) -> str:
|
|||
re.compile(
|
||||
r"((?:{%|{{\#)[ ]*?(?:"
|
||||
+ config.break_template_tags
|
||||
+ ")[^}]+?[%|}]})(?=[^\n])",
|
||||
+ ")[^}]+?[%}]})(?=[^\n])",
|
||||
flags=re.IGNORECASE | re.MULTILINE | re.VERBOSE,
|
||||
),
|
||||
partial(should_i_move_template_tag, "%s\n"),
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ run::
|
|||
pytest tests/test_handlebars.py --cov=src/djlint --cov-branch \
|
||||
--cov-report xml:coverage.xml --cov-report term-missing
|
||||
|
||||
pytest tests/test_handlebars.py::test_each --cov=src/djlint --cov-branch \
|
||||
pytest tests/test_handlebars/test_each.py::test_each_with_pipe --cov=src/djlint --cov-branch \
|
||||
--cov-report xml:coverage.xml --cov-report term-missing
|
||||
|
||||
"""
|
||||
|
|
@ -34,3 +34,12 @@ def test_each(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
{{/each }}
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def test_each_with_pipe(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
output = reformat(
|
||||
tmp_file,
|
||||
runner,
|
||||
b"""{{#each (cprFindConfigObj "inventoryCategories") as |category c |}}\n""",
|
||||
)
|
||||
assert output.exit_code == 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue