From 1da2840071cfb398619d4e7ce7e4ee4d766809aa Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 17 Aug 2025 12:52:31 +0200 Subject: [PATCH] Fix book code examples --- book/src/filters.md | 6 +++--- book/src/template_syntax.md | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/book/src/filters.md b/book/src/filters.md index 8928c869..85a3f666 100644 --- a/book/src/filters.md +++ b/book/src/filters.md @@ -104,7 +104,7 @@ Output: ### default [#default]: #default -```jinja +```text {{ variable_or_expression | default(default_value) }} {{ variable_or_expression | default(default_value, [[boolean =] true]) }} ``` @@ -285,7 +285,7 @@ enabled by "alloc"
enabled by "default" -```jinja +```text {{ "format_string" | format([variables ...]) }} ``` @@ -468,7 +468,7 @@ hello ### `pluralize` [#pluralize]: #pluralize -```jinja +```text {{ integer | pluralize }} {{ integer | pluralize([singular = ""], [plural = "s"]) }} ``` diff --git a/book/src/template_syntax.md b/book/src/template_syntax.md index ffdbb65c..c0632851 100644 --- a/book/src/template_syntax.md +++ b/book/src/template_syntax.md @@ -557,7 +557,7 @@ const x = {{ x is defined }}; Due to proc-macro limitations, askama can only see the fields of your current type and the variables declared in the templates. Because of this, you can not check if a field or a function is defined: -```jinja +```jinja,error {% if x.y is defined %} This code will not compile {% endif %} @@ -650,7 +650,7 @@ you can also use an optional `{% endwhen %}` node to close a `{% when %}` case: {% when 1 | 3 | 5 | 7 | 9 %} odd {% endwhen %} - {% else } + {% else %} unknown {% endmatch %} ``` @@ -885,7 +885,7 @@ To have a small library of reusable snippets, it's best to declare the macros in Additionally to specifying arguments positionally, you can also pass arguments by name. This allows passing the arguments in any order: ```jinja -{% macro heading(title, font_weight = "normal", font_size = 13)} +{% macro heading(title, font_weight = "normal", font_size = 13) %}

{{ title }}

@@ -949,7 +949,7 @@ Invoking this macro using the call expression syntax shown above (`{{ centered() However, you can declare macros in a way that allows invoking them with and without body: ```jinja -{% macro render_dialog(title, class='dialog') -%} +{% macro render_dialog(title, class="dialog") -%}

{{ title }}

@@ -1010,7 +1010,7 @@ Macro invocations instantly overwrite the `caller` variable with their own. To b
{{ caller() }}
-{% endmacro } +{% endmacro %} {% macro outer_container() %} {# Create an alias to our `caller`, so we can access it within container: #} @@ -1020,7 +1020,7 @@ Macro invocations instantly overwrite the `caller` variable with their own. To b {# nested macro invocation - will overwrite the `caller` variable: #} {% call container() %} {{ outer_caller() }} - {% endmacro %} + {% endcall %}
{% endmacro %} ```