Description
Source
<div class="always-present{% if withCollapse %}with-collapse" data-toggle="collapse"{% else %}no-collapse"{% endif %}>
<p>Thingy here, possibly with collapse attached.</p>
</div>
Result after beautify
<div class="always-present{% if withCollapse %}with-collapse" data-toggle="collapse" {% else %} no-collapse="no-collapse"
Problem
The {% endif %}
and everything afterwards just get stripped away!
Story
I ran into this issue with titles that only sometimes have a collapsed attached.
To achieve different styling, I add different classes depending on some logic.
Trying to be clever, I also wanted to add other HTML attributes using the same logic.
When wanting a collapse, I add the class with-collapse
to the class-attribute.
Also, I add the data-toggle="collapse"
attribute.
When not wanting a collapse, I add the class no-collapse
to the class-attribute.
The data-toggle-attribute is omitted in this case.
I realize this is messy HTML to begin with and it might be bad practice to use if-clauses to split HTML attributes the way I did.
PHPStorm already warns me that not all tags are claused since it somehow cannot handle the entanglement of attributes and if-clauses, too.
But still I think just deleting stuff is not a sane way to handle this ;)
Please excuse me if you find the bug report lacking or peculiar somehow, this is my first time ;)
PS: Turning the logic around makes no difference.
Source
<div class="always-present{% if noCollapse %} no-collapse"{% else %}with-collapse" data-toggle="collapse"{% endif %}>
<p>Thingy here, possibly with collapse attached.</p>
</div>
Result
<div class="always-present{% if noCollapse %} no-collapse" {% else %} with-collapse" data-toggle=" collapse="collapse"
Edits for layout.