djc / askama

Type-safe, compiled Jinja-like templates for Rust
Apache License 2.0
3.43k stars 218 forks source link

Using block fragments as part of larger template #1049

Closed eliasgranse closed 4 months ago

eliasgranse commented 4 months ago

I am trying to use the feature called "block fragments" as described in the book, section "Block Segments". The block fragment I am trying to create is part of a larger template and the Rust code looks like this:

#[derive(Template)]
#[template(path = "pages/index.html", block = "my_block")]
pub struct MyTemplate {}

However the line #[derive(Template)] stops on the error:

unsupported attribute key Ident { ident: "block", span: #0 bytes(16214..16219) } found

Looking at the Docs.rs documentation this feature is not documented which makes me think this is not supported for some reason.

Anyways, I cannot seem to figure out what I am doing wrong. Thanks!

djc commented 4 months ago

The block fragment feature hasn't been released yet. See #1035 for release planning -- you could use main for now.

eliasgranse commented 4 months ago

I see thanks for responding so quickly!

Astralchroma commented 2 months ago

I've just been tripped up by this as well. Perhaps don't include features in the book that don't actually exist yet, or at least a warning?

matjazonline commented 1 month ago

PR here https://github.com/djc/askama/pull/1084