fix(alpine.js): fixed formatting in alpine.js attributes

fixes #240
This commit is contained in:
Christopher Pickering 2022-05-09 12:19:28 -05:00
parent 98dd52e488
commit e531701238
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
2 changed files with 14 additions and 3 deletions

View file

@ -627,8 +627,8 @@ class Config:
| (?:[^\s]+?=(?:\".*?\"|\'.*?\'))
| required
| checked
| [\w|-]+
| [\w|-]+=[\w|-]+
| (?:\w|-|\.)+
| (?:\w|-|\.)+=(?:\w|-)+
| {{.*?}}
| {%.*?%}
"""

View file

@ -7,7 +7,7 @@ run::
for a single test, run::
pytest tests/test_django.py::test_comment --cov=src/djlint \
pytest tests/test_django.py::test_alpine_js --cov=src/djlint \
--cov-branch --cov-report xml:coverage.xml --cov-report term-missing
"""
@ -54,6 +54,17 @@ def test_reformat_asset_tag(runner: CliRunner, tmp_file: TextIO) -> None:
assert output.exit_code == 1
def test_alpine_js(runner: CliRunner, tmp_file: TextIO) -> None:
output = reformat(
tmp_file, runner, b"""<div id="collapse"
x-data="{ show: true }"
x-show="show"
x-transition.duration.500ms></div>"""
)
assert output.exit_code == 0
def test_autoescape(runner: CliRunner, tmp_file: TextIO) -> None:
output = reformat(
tmp_file, runner, b"{% autoescape on %}{{ body }}{% endautoescape %}"