askama: askama_axum v0.2 error with Template

after update askama_axum to 0.2 (ref #756) i get following error and with the propose use statement

error[E0412]: cannot find type `BoxBody` in crate `askama_axum`
  --> mycrate\src\main.rs:11:10
   |
11 | #[derive(Template)]
   |          ^^^^^^^^ not found in `askama_axum`
   |
   = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this type alias
   |
1  | use axum::body::BoxBody;
   |
help: if you import `BoxBody`, refer to it directly
   |
11 | #[derive(Template)]

code similar to example at https://github.com/djc/askama/blob/main/askama_axum/tests/basic.rs

error on #[derive(Template)]

use askama::Template;
use axum::{
    extract,
    http::StatusCode,
    response::{Html, IntoResponse, Response},
    routing::{get, MethodRouter},
    Router,
};

#[derive(Template)]
#[template(path = "hello.html")]
struct HelloTemplate {
    name: String,
}

is why cargo upgrade mark update incompatible?

name        old req compatible latest new req note        
====        ======= ========== ====== ======= ====
anyhow      1.0.68  1.0.68     1.0.68 1.0.68
askama      0.11.1  0.11.1     0.11.1 0.11.1
askama_axum 0.1.0   0.1.0      0.2.0  0.1.0   incompatible
axum        0.6.1   0.6.1      0.6.1  0.6.1
tokio       1.23.0  1.23.0     1.23.0 1.23.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I took a look at the version of askama_shared uploaded to crates.io, and I think this is the source of the issue: On line 224 of src/generator.rs of the published version of the crate, the code to be generated includes ::askama_axum::BoxBody, which is no longer re-exported by askama_axum (it was in 0.1.0, it’s not in 0.2.0).

It looks like the version of askama_shared in the 0.11.x branch shouldn’t have this issue, so I believe this issue could be resolved by publishing the new version of askama_shared to crates.io.

Same problem here. Deps versions like @bouncydingbat .

@fomigas131a Please keep in mind that (I assume) the maintainers of this repo do so for free. It can be frustrating waiting for a fix, but you don’t know what other things may be going on which are blocking this issue behind the scenes, and being kind costs nothing 😃

Changing this in askama_shared in a 0.11.x bump will cause issues for people who are still using older Axum versions. Can someone test if the fix in #758 works?