From e5317012388892a5f9f97faf17aebace84c30b78 Mon Sep 17 00:00:00 2001 From: Christopher Pickering Date: Mon, 9 May 2022 12:19:28 -0500 Subject: [PATCH] fix(alpine.js): fixed formatting in alpine.js attributes fixes #240 --- src/djlint/settings.py | 4 ++-- tests/test_django.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/djlint/settings.py b/src/djlint/settings.py index 6c4c66d..aedd156 100644 --- a/src/djlint/settings.py +++ b/src/djlint/settings.py @@ -627,8 +627,8 @@ class Config: | (?:[^\s]+?=(?:\".*?\"|\'.*?\')) | required | checked - | [\w|-]+ - | [\w|-]+=[\w|-]+ + | (?:\w|-|\.)+ + | (?:\w|-|\.)+=(?:\w|-)+ | {{.*?}} | {%.*?%} """ diff --git a/tests/test_django.py b/tests/test_django.py index c4d4e79..a8eae93 100644 --- a/tests/test_django.py +++ b/tests/test_django.py @@ -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"""
""" + ) + + assert output.exit_code == 0 + + def test_autoescape(runner: CliRunner, tmp_file: TextIO) -> None: output = reformat( tmp_file, runner, b"{% autoescape on %}{{ body }}{% endautoescape %}"