Announcing Askama 0.7.0

I’m excited to announce a new release of Askama, the type-safe, compiled Jinja-like template engine for Rust. Among other things, this is what actix-web uses in their TechEmpower benchmarks. Note that this release relies on Rust features first released in 1.26.0.

The most interesting new feature in this release is an overhauled inheritance model:

  • _parent fields are no longer needed (but still supported for compatibility)
  • Supported for multi-layer inheritance has been implemented
  • Blocks can now be defined inside other blocks
  • The super() macro can be used to call parent blocks from inside a block
  • Removes the need for elaborate imports for inheritance across modules
  • Fixes some issues with extends paths on Windows

For this release I finally spent some time collecting benchmarks for template engines. The results can be found in this GitHub repository. I was happy to see that Askama performance seems more than competitive compared to popular alternatives.

Smaller improvements in this release:

  • Add support for Range expressions (a..b; see #95)
  • Add support for Index operation (a[b]; see #95)
  • Allow methods to be called on self
  • Add support for loop.first variable
  • Add a simple truncate filter (see #95)
  • Matching is more robust thanks to match binding modes (fixes #94)
  • askama::Error is now Send + Sync + 'static
  • Renamed lifetime on Rocket integration to prevent conflicts (fixes #88)
  • Upgrades to nom 4, syn 0.14 and quote 0.6

Thanks to Mika Lehtinen and Philipp Korber for contributing code to this release, and to everyone else who submitted feedback for their support in further improving Askama.

I recently started a Patreon page. If you are in a position to support ongoing maintenance and further development of Askama or use it in a for-profit context, please consider supporting my work!


Some nice new features are now available as part of Askama 0.7.1. The most important one is the ability to search multiple directories for template files. This works by adding an askama.toml file to the crate root and specifying the search directories in there (see the documentation). Now that there is a configuration mechanism, this may unlock other potential features that rely on some way to specify out-of-band configuration.

This release also adds optional support for actix-web. If you enable the with-actix-web feature, Template derives will include an impl for actix-web’s Responder trait, so that you can trivially return template context structs from actix-web handlers.

  • Add support for multiple template directories (thanks to @mashedcode)
  • Add impl for actix-web Responder trait (thanks to @ryanmcgrath)
  • Add linebreaks and linebreaksbr filters (thanks to @XAMPPRocky)
  • Allow Template users to inspect template extension() (thanks to @ryanmcgrath)
  • derive(Template) is no longer restricted to named field struct types
1 Like

After two months, I’m happy to announce the 0.7.2 release of Askama, the type-safe, compiled Jinja-like template engine for Rust! Despite the small version number increase (because this release should be fully backwards compatible with earlier 0.7 releases), there’s a good amount of feature in this release. Happily, I can say that for the first time, all of the improvements in this release are due to @botika spending a lot of time on improving Askama over the past months, for which I owe them many thanks! Let’s dive in:

  • Custom syntax support: in response to a bug reporter who wanted to generate LaTeX with Askama (#121), it is now possible to use custom block delimiters in your Askama templates. Read the documentation for more information on how to define and use custom syntaxes. Thanks to @botika for spending a lot of time on getting this just right.
  • Added a number of built-in filters: abs, capitalize, center and wordcount
  • Fixed support for range-based for-loops (#117) by specializing the code generator
  • Fixed operator precedence issues with loop attributes (like index)
  • Fixed a number of edge cases in macro scope resolution