New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Twig: Splitting HTML Attribute with an IF-clause will cause deletion! #621
Comments
christophhapple
changed the title
Splitting HTML Attribute with an IF-clause will cause deletion!
Twig: Splitting HTML Attribute with an IF-clause will cause deletion!
Sep 26, 2019
panoply
added a commit
to panoply/esthetic
that referenced
this issue
Jul 10, 2022
In addition, this commit also addresses the PrettyDiff issue caused by Angle Brackets being processed as HTML delimiters and thus breaking the parse when lexing Liquid attributes. The actual issue was submitted for Twig but also wreaked havoc in Liquid. This defect was fixed by keeping track of entry points of tokens, ie: when we are within a Liquid template tag ({{ or {%) > (%} or }}) then we assigned a variable which allows us to skip interception of angle brackets that were being used in control based conditions like {% if x > 1 %} See: prettydiff/prettydiff#621
panoply
added a commit
to panoply/esthetic
that referenced
this issue
Jul 10, 2022
In addition, this commit also addresses the PrettyDiff issue caused by Angle Brackets being processed as HTML delimiters and thus breaking the parse when lexing Liquid attributes. The actual issue was submitted for Twig but also wreaked havoc in Liquid. This defect was fixed by keeping track of entry points of tokens, ie: when we are within a Liquid template tag ({{ or {%) > (%} or }}) then we assigned a variable which allows us to skip interception of angle brackets that were being used in control based conditions like {% if x > 1 %} See: prettydiff/prettydiff#621
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source
Result after beautify
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
Result
Edits for layout.
The text was updated successfully, but these errors were encountered: