askama icon indicating copy to clipboard operation
askama copied to clipboard

Unnecessary fields required when using blocks for partial rendering

Open Tortoaster opened this issue 9 months ago • 3 comments

Given a template like this:

templates/base.html

{% block empty %}
{% endblock %}

{% if let Some(var) = var %}
{{ var }}
{% endif %}

The following code:

#[derive(Template)]
#[template(path = "base.html", block = "empty")]
struct Empty {}

Gives an error:

no field `var` on type `&Empty`

Due to the (empty) match statement generated by the derive macro, even though the field var is not necessary to render just the empty block.

Tortoaster avatar May 20 '24 19:05 Tortoaster