Skip to content
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

Custom tag indentation #190

Open
Daniel-Knights opened this issue Mar 24, 2023 · 5 comments
Open

Custom tag indentation #190

Daniel-Knights opened this issue Mar 24, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@Daniel-Knights
Copy link

Daniel-Knights commented Mar 24, 2023

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
@Daniel-Knights Daniel-Knights added the Bug Something isn't working label Mar 24, 2023
@Daniel-Knights
Copy link
Author

Daniel-Knights commented Mar 24, 2023

Actually only seems to do this with the capture tag:

21b96afd93386499cc51004e656f2086.mp4

@charlespwd
Copy link
Contributor

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.

@Daniel-Knights
Copy link
Author

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

@charlespwd
Copy link
Contributor

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).

@Daniel-Knights
Copy link
Author

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!

@charlespwd charlespwd transferred this issue from Shopify/prettier-plugin-liquid Oct 23, 2023
@mgmanzella mgmanzella added the Severity: 4 theme bugs that won't be prioritized in the near future label Jun 17, 2024
@mgmanzella mgmanzella added enhancement New feature or request and removed Bug Something isn't working Severity: 4 theme bugs that won't be prioritized in the near future labels Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants