mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-04 03:44:43 +00:00
added rstrip to attributes after formatting. updated tests. closes #69
This commit is contained in:
parent
863efbf116
commit
d6c6e49f19
2 changed files with 7 additions and 3 deletions
|
|
@ -157,4 +157,7 @@ def format_attributes(config: Config, match: re.match) -> str:
|
|||
# format template tags
|
||||
attributes = format_template_tags(config, attributes)
|
||||
|
||||
# clean trailing spaces added by breaks
|
||||
attributes = "\n".join([x.rstrip() for x in attributes.splitlines()])
|
||||
|
||||
return f"{attributes}"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ run::
|
|||
|
||||
for a single test, run::
|
||||
|
||||
pytest tests/test_django.py::test_empty_tags_on_one_line --cov=src/djlint \
|
||||
pytest tests/test_django.py::test_complex_attributes --cov=src/djlint \
|
||||
--cov-branch --cov-report xml:coverage.xml --cov-report term-missing
|
||||
|
||||
"""
|
||||
|
|
@ -312,13 +312,14 @@ def test_complex_attributes(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
output = reformat(
|
||||
tmp_file,
|
||||
runner,
|
||||
b"""<a class="{% if favorite == "yes" %}favorite{% endif %} has-tooltip-arrow has-tooltip-right" data-tooltip="{% if favorite == "yes" %}Remove from Favorites {% else %}Add to Favorites{% endif %}" fav-type="report" object-id="{{ report.report_id }}"><span class="icon has-text-grey is-large "><i class="fas fa-lg fa-star"></i></span></a>""",
|
||||
b"""<a class="asdf {% if favorite == "yes" %}favorite{% endif %} has-tooltip-arrow has-tooltip-right" data-tooltip="{% if favorite == "yes" %}Remove from Favorites {% else %}Add to Favorites{% endif %}" fav-type="report" object-id="{{ report.report_id }}"><span class="icon has-text-grey is-large "><i class="fas fa-lg fa-star"></i></span></a>""",
|
||||
)
|
||||
assert output["exit_code"] == 1
|
||||
|
||||
assert (
|
||||
output["text"]
|
||||
== r"""<a class="{% if favorite == "yes" %}
|
||||
== r"""<a class="asdf
|
||||
{% if favorite == "yes" %}
|
||||
favorite
|
||||
{% endif %}
|
||||
has-tooltip-arrow has-tooltip-right"
|
||||
|
|
|
|||
Loading…
Reference in a new issue