Skip to content

Commit

Permalink
support some missing Jinja blocks (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownPlatypus committed Jun 11, 2024
1 parent 28da3ac commit 5bc7f82
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions markup_fmt/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,9 @@ impl<'s> Parser<'s> {
| "autoescape"
| "embed"
| "with"
| "set"
| "trans"
| "raw"
) {
let mut body = vec![JinjaTagOrChildren::Tag(first_tag)];

Expand Down
26 changes: 26 additions & 0 deletions markup_fmt/tests/fmt/jinja/control-structure/fixture.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,29 @@ Sold-out!
{%- endmacro %}

<title>{% block title %}{% endblock %}</title>

{% set reply | wordwrap %}
You wrote:
{{ message }}
{% endset %}

{% trans %}Hello, {{ user }}!{% endtrans %}
{% trans user=user.username %}Hello, {{ user }}!{% endtrans %}

{% trans book_title=book.title, author=author.name %}
This is {{ book_title }} by {{ author }}
{% endtrans %}

{% trans count=list|length %}
There is {{ count }} {{ name }} object.
{% pluralize %}
There are {{ count }} {{ name }} objects.
{% endtrans %}

{% raw %}
<ul>
{% for item in seq %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{% endraw %}
28 changes: 28 additions & 0 deletions markup_fmt/tests/fmt/jinja/control-structure/fixture.snap
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,31 @@ source: markup_fmt/tests/fmt.rs
{%- endmacro %}

<title>{% block title %}{% endblock %}</title>

{% set reply | wordwrap %}
You wrote:
{{ message }}
{% endset %}

{% trans %}Hello, {{ user }}!{% endtrans %}
{% trans user=user.username %}Hello, {{ user }}!{% endtrans %}

{% trans book_title=book.title, author=author.name %}
This is {{ book_title }} by {{ author }}
{% endtrans %}

{% trans count=list|length %}
There is {{ count }}
{{ name }} object.
{% pluralize %}
There are {{ count }}
{{ name }} objects.
{% endtrans %}

{% raw %}
<ul>
{% for item in seq %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{% endraw %}

0 comments on commit 5bc7f82

Please sign in to comment.