Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Unnecessary fields required when using blocks for partial rendering #1052

Open
Tortoaster opened this issue May 20, 2024 · 3 comments
Open

Comments

@Tortoaster
Copy link

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.

@GuillaumeGomez
Copy link
Collaborator

Normally it was fixed in #1029. Please try with the main branch to confirm it was fixed.

@Tortoaster
Copy link
Author

I'm afraid the issue is still there, I tested it on main (c1366e0).

@GuillaumeGomez
Copy link
Collaborator

Ok! Gonna take a look in the next hours.

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

Successfully merging a pull request may close this issue.

2 participants