theme-tools
theme-tools copied to clipboard
Custom tag indentation
I'm using LiquidJS which provides a custom block
tag, this plugin doesn't indent the content within this tag correctly, treating anything inside as being on the same level.
Is this intended?
Unformatted source
{% block "popups" %}
{% capture content %}
<div>Hi</div>
{% endcapture %}
{% render "popup", id: "hi", content: content %}
{% endblock %}
Expected output
Unchanged.
Actual output
{% block "popups" %}
{% capture content %}
<div>Hi</div>
{% endcapture %}
{% render "popup", id: "hi", content: content %}
{% endblock %}
Debugging information
- Windows
- 1.0.6
Actually only seems to do this with the capture
tag:
https://user-images.githubusercontent.com/59598622/227581126-7e96eb49-ae0e-4d11-8d9b-5f278429489f.mp4
The capture tag is indentation sensitive. Changing the indentation changes the value of the string, therefore the content isn't reindented. That's because we can't change the semantic meaning of the file when reformatting.
That said, it is true we don't support custom tags right now.
Ah right, that makes sense. Is there a way to preserve indentation within the block tag? Looks a bit odd having everything within at the same level
Not at the moment unfortunately. What's happening right now is that, because the tag isn't recognized, both the block
and endblock
tag fall into our liquidTagBaseCase
which takes any name and markup.
As it is, all tags that take children have to be explicitly defined in our parser. If we don't, then the parser would be ambiguous (we need to know if it can have children to push nodes as children, else we push as sibling).
Fair enough, would be a nice feature to pass custom tag definitions somehow, but understand that's probably not as simple as it sounds.
I'll leave this issue open, in case you wanna keep it, but feel free to close it now. Thanks for the explanation!