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

feat: improve formatting Jinja blocks in attributes #44

Merged
merged 2 commits into from
Aug 17, 2024

Conversation

g-plane
Copy link
Owner

@g-plane g-plane commented Aug 16, 2024

Please note that interpolations in attribute name and attribute value won't be formatted. This is expected since they're parsed as plain texts.

cc @UnknownPlatypus

@UnknownPlatypus
Copy link
Contributor

Please note that interpolations in attribute name and attribute value won't be formatted. This is expected since they're parsed as plain texts.

I think it's better like that for now. Parsing and formatting interpolation in attribute value will add complexity and is not always safe if whitespace are important (in href values for example)

Comment on lines +112 to +114
{% if index_type == "foo" %}
style="display: none"
{% endif %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this always break even if the print width is not exceeded ? Maybe i'm not counting right but the line was initially of width 60 so I'm not sure it should have wrapped ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially I tried it but I found that will be ugly.

Comment on lines +77 to +81
data-start="08:30:00"
data-end="20:30:00"
data-start_day='{% now "Y-m-d" %}'
data-saturday_start="08:30:00"
data-saturday_end="20:30:00"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great 🥳

@g-plane g-plane merged commit 941308b into main Aug 17, 2024
1 check passed
@g-plane g-plane deleted the jinja-blocks-in-attrs branch August 17, 2024 06:29
@UnknownPlatypus
Copy link
Contributor

@g-plane This seems to cause an issue for the following snippet that is not parsing anymore:

<picture
    {% for key, val in attributes.items %} 
        {{ key }}="{{ val }}"
    {% endfor %}
></picture>

I get this Failed to parse "src/t.html" with error Syntax(SyntaxError { kind: ExpectJinjaTag, pos: 61, line: 3, column: 11 }). This is failing to parse {{ key }} because it expect a JinjaTag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants