djc / askama

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

Getting Error trying to add Template to child #1094

Closed TrevorSatori closed 13 hours ago

TrevorSatori commented 14 hours ago

I have a basic struct and base.html. Inside the base.html I want to add a navbar which I have in my nav.html. I have tried both {% include "nav.html" with { "active_page" = active_page } %} and {% include "nav.html" %}. However I get "Problems parsing template source at row 60, column 66 near: "with { \"active_page\" = active_page } %}\r" when I do {% include "nav.html" with { "active_page" = active_page } %} and I get mbe parse error with {% include "nav.html" with { "active_page" = active_page } %}. The rust compiler says error: character literal may only contain one codepoint for #[derive(Template)] when I have {% include "nav.html" with { "active_page" = active_page } %}. Been troubleshooting for a while and believe this is a bug or lack of documentation.

[derive(Template)]

[template(path = "home.html")]

struct HomePage<'a> { title: &'a str, meta_content: &'a str, canonical_extension: &'a str, active_page: &'a str, }

TrevorSatori commented 14 hours ago

And as usual, right after posting the fix I figure out the issue. The problem was due to my nav.html and the way the quotations were used in the actual html.