Improve formatting of Jinja blocks#205
Conversation
✅ Deploy Preview for markup-fmt ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
3518f4b to
1c0051f
Compare
1c0051f to
20af8b3
Compare
|
@g-plane I found an interesting case where this is unsafe to apply the current changes, jinja trans block - {% trans %}Your server has exceeded the limit for how often this action can be performed.{% endtrans %}
+ {% trans %}
+ Your server has exceeded the limit for how often this action can be performed.
+ {% endtrans %}How can we manage to have the information about the parent jinja tag inside Finding other edge cases that make me think this is much more involved than I thought. For exemple this change would be incorrect too I think: _('Organization URL')
}}</label>
<div id="id_realm_subdomain" class="not-editable-realm-field">
- {% if form.realm_subdomain.value() %}{{ form.realm_subdomain.value() }}.{%
- endif
- %}{{ external_host }}
+ {% if form.realm_subdomain.value() %}
+ {{ form.realm_subdomain.value() }}.
+ {% endif %}{{ external_host }}
</div>
</div>
</div> |
|
We can limit the behavior of inserting line breaks to a set of known tags, but don't do this check in |
We should do it in the doc implementation of JinjaTag then ? |
|
Maybe in |
Given this:
It was previously getting formatted to this:
And will now respect the whitespace sensitivity of the parent node (the
ptag here) and be formatted like so:I think it make sense because jinja block/tags basically disapear when rendered.
Test cases come from real world exemple were the formatting was weird previously.
You can see the before in this commit, and the after in the last commit