Upgrading to new versions
This file only lists breaking changes you need to be aware of when you upgrade to a new askama version. Please see our release notes to get a list of all changes and improvements that might be useful to you.
From askama v0.15 to askama v0.16
-
Variable creation without value cannot be done with
let/setanymore. You need to use the newdecl/declareinstead:{% decl variable_without_value %} -
Duplicated blocks will now error and prevent compilation instead of emitting a warning.
From askama v0.14 to askama v0.15
-
The MSRV of this release is 1.88.
-
Filter functions now need to have the
filter_fnproc-macro used on them. So if you had:pub fn to_string(s: impl ToString, _: &dyn Values) -> Result<String> { Ok(s.to_string()) }It now becomes:
#[askama::filter_fn] pub fn to_string(s: impl ToString, _: &dyn Values) -> Result<String> { Ok(s.to_string()) } -
Variables declared in the templates cannot be named
calleranymore.
From askama v0.13 to askama v0.14
-
The MSRV of this release is 1.83.
-
When assigning a new variable (
{% let var = … %}) with a local variable was value, it is moved or copied, not referenced. -
Try expressions (
{{ expr? }}) are not placed behind a reference. -
FastWritableimplementations have access to runtime values. -
Custom filters have access to runtime values, and must add a second
&dyn askama::Valuesargument as in the example. -
|uniqueis a built-in filter;|titlecaseis an alias for|title.
From askama v0.12 to askama v0.13
A blog post summarizing changes and also explaining the merge of rinja and askama is
available here.
List of breaking changes:
-
The MSRV of this release is 1.81.
-
The integration crates were removed. Instead of depending on e.g.
askama_axum/askama_axum, please usetemplate.render()to render to aResult<String, askama::Error>.Use e.g.
.map_err(|err| err.into_io_error())?if your web-framework expectsstd::io::Errors, orerr.into_box()if it expectsBox<dyn std::error::Error + Send + Sync>.Please read the documentation of your web-framework how to turn a
Stringinto a web-response. -
The fields
Template::EXTENSIONandTemplate::MIME_TYPEwere removed. -
You may not give variables a name starting with
__askama, or the name of a rust keyword. -
#[derive(Template)]cannot be used withunions. -
|linebreaks,|linebreaksbrand|paragraphbreaksescape their input automatically. -
|jsondoes not prettify its output by default anymore. Use e.g.|json(2)for readable output. -
The binary operators
|,&and^are now calledbitor,bitandandxor, resp. -
The feature
"humansize"was removed. The filter|humansizeis always available. -
The feature
"serde-json"is now called"serde_json". -
The feature
"markdown"was removed. Usecomrakdirectly. -
The feature
"serde-yaml"was removed. Use e.g.yaml-rust2directly.
From rinja v0.3 to askama v0.13
-
The MSRV of this release is 1.81.
-
The projects rinja and askama were re-unified into one project. You need to replace instances of
rinjawithaskama, e.g.-use rinja::Template; +use askama::Template;[dependencies] -rinja = "0.3.5" +askama = "0.13.0" -
The integration crates were removed. Instead of depending on e.g.
rinja_axum/askama_axum, please usetemplate.render()to render to aResult<String, askama::Error>.Use e.g.
.map_err(|err| err.into_io_error())?if your web-framework expectsstd::io::Errors, orerr.into_box()if it expectsBox<dyn std::error::Error + Send + Sync>.Please read the documentation of your web-framework how to turn a
Stringinto a web-response. -
The fields
Template::EXTENSIONandTemplate::MIME_TYPEwere removed. -
The feature
"humansize"was removed. The filter|humansizeis always available. -
You may not give variables a name starting with
__rinja, or the name of a rust keyword. -
#[derive(Template)]cannot be used withunions.
From rinja v0.2 to rinja v0.3
- You should be able to upgrade to v0.3 without changes.
From askama v0.12 to rinja v0.2
Have a look at our blog posts that highlight some of the best features of our releases, and give you more in-dept explanations: docs.rs switching jinja template framework from tera to rinja.
-
The MSRV of this release is 1.71.
-
You need to replace instances of
askamawithrinja, e.g.-use askama::Template; +use rinja::Template;[dependencies] -askama = "0.12.1" +rinja = "0.2.0" -
|linebreaks,|linebreaksbrand|paragraphbreaksescape their input automatically. -
|jsondoes not prettify its output by default anymore. Use e.g.|json(2)for readable output. -
The binary operators
|,&and^are now calledbitor,bitandandxor, resp. -
Filter
as_refis now justref -
The feature
"serde-json"is now called"serde_json". -
The feature
"markdown"was removed. Usecomrakdirectly. -
The feature
"serde-yaml"was removed. Use e.g.yaml-rust2directly.
From askama v0.11 to askama v0.12
-
The magic
_parentfield to access&**selfwas removed. -
Integration implementations do not need an
extargument anymore. -
The
ironintegration was removed.