samuelcolvin / jinjahtml-vscode

Syntax highlighting for jinja(2) html templates in vscode
https://marketplace.visualstudio.com/items?itemName=samuelcolvin.jinjahtml
MIT License
135 stars 53 forks source link

Is there way to configure indentation? #124

Closed capymind closed 1 year ago

capymind commented 1 year ago

First of all, really appreciate for sharing this literally wonderful extensions, helping thousands of (if not millions) developers out there. πŸ”₯πŸ™

I have some trivial(tiny) issue(question) about identation configuration. Sorry for bothering you, this issue may be caused by my insufficient understanding about VSCode and extension.. (I don't know other place to question about it)

My current code format results in something like that below

<div class="row pt-4 g-3">
    <div class="col-6">
        {% with error = get_flashed_messages(category_filter=["error.login.username"]) %}
        {% if error %}
        <div class="input-group has-validation">
            <input
                id="username"
                name="username"
                type="text"
                class="form-control is-invalid"
                placeholder="아이디"
                aria-label="아이디"
                aria-describedby="usernameFeedback"
            >
            <div
                id="usernameFeedback"
                class="invalid-feedback"
            >
                [!!!] μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” μ‚¬μš©μžμž…λ‹ˆλ‹€(아이디: {{ request.form.get("username") }})
            </div>
        </div>
        {% else %}
        <div class="input-group">
            <input
                id="username"
                name="username"
                type="text"
                class="form-control"
                placeholder="아이디"
                aria-label="아이디"
            >
        </div>
        {% endif %}
        {% endwith %}
    </div>
</div>

But the indentation that I want to be is below, considering nested structure(with, if, for etc..)

<div class="row pt-4 g-3">
    <div class="col-6">
        {% with error = get_flashed_messages(category_filter=["error.login.username"]) %}
          {% if error %} <!-- πŸŸ’πŸ‘ˆ indented one level further!! -->
            <div class="input-group has-validation"> <!-- πŸŸ’πŸ‘ˆ indented one level further!! -->
                <input
                    id="username"
                    name="username"
                    type="text"
                    class="form-control is-invalid"
                    placeholder="아이디"
                    aria-label="아이디"
                    aria-describedby="usernameFeedback"
                >
                <div
                    id="usernameFeedback"
                    class="invalid-feedback"
                >
                    [!!!] μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” μ‚¬μš©μžμž…λ‹ˆλ‹€(아이디: {{ request.form.get("username") }})
                </div>
            </div>
          {% else %} <!-- πŸŸ’πŸ‘ˆ indented one level further!! -->
            <div class="input-group"> <!-- πŸŸ’πŸ‘ˆ indented one level further!! -->
                <input
                    id="username"
                    name="username"
                    type="text"
                    class="form-control"
                    placeholder="아이디"
                    aria-label="아이디"
                >
            </div>
          {% endif %} <!-- πŸŸ’πŸ‘ˆ indented one level further!! -->
        {% endwith %}
    </div>
</div>

Is there way to change the way indentation is applied above?

Thanks a lot again for inventing, sharing, maintaining this invaluablue open source project. Best Regards

Happy new yearπŸŽ‰

samuelcolvin commented 1 year ago

Happy new year.

I don't know of any way to customise indentation in an extension, though I imagine it might be possible.

As far as I remember, we don't do anything special currently.

capymind commented 1 year ago

Thank you for a quick and helpful reply, despite the fact that you are (so) busy... (related to coming pydantic v2 maybe..?)

I will check the other places. Thanks a lot again.

samuelcolvin commented 1 year ago

Thanks for understanding, ye pydantic V2 is consuming a lot of time.

RyanBaig commented 10 months ago

@samuelcolvin Maybe you can add some formatter for these .jinja files. that can work, right?