wearedestination / prettier-plugin-twig

Prettier Twig/HTML plugin
MIT License
6 stars 1 forks source link

{% block %} tags don't indent children #1

Closed TomoyaHamasaki closed 6 months ago

TomoyaHamasaki commented 6 months ago

{% block %} tags don't indent the children inside. Are there any plans to add this? I've been trying to add it myself with no luck.

{% block blockName %}

{% endblock %} or {% endblock blockName %}

I really appreciate your plugin since it's the cleanest one and and the only one that works with html.twig

TomoyaHamasaki commented 6 months ago

Nevermind, I figured it out. I just added "block" in the blockName section

liquid-html.ohm liquid-html.ohm.js

blockName =
    // Shopify blocks
    ( "form"
    | "paginate"
    // Base blocks
    | "capture"
    | "case"
    | "for"
    | "ifchanged"
    | "if"
    | "unless"
    | "tablerow"
    ) endOfIdentifier

to this

blockName =
    // Shopify blocks
    ( "form"
    | "paginate"
    // Base blocks
    | "capture"
    | "case"
    | "for"
    | "ifchanged"
    | "if"
    | "unless"
    | "tablerow"
    | "block" <--- add this line in each file
    ) endOfIdentifier
andyexeter commented 6 months ago

We've added this in https://github.com/wearedestination/prettier-plugin-twig/commit/66057177c18398a9a56c58d9a61180a3f8c7aad4 and released it as v1.3.0 - thanks!

TomoyaHamasaki commented 5 months ago

You might want to add 2 more as well

| "embed"
| "macro"

If you can somehow find a way to get {% set %}{% endset %} to work as well; that would be suss.