Type-safe, compiled Jinja-like templates for Rust
After 13 months of development, we're happy to announce the 0.12.0 release of Askama, the type safe, compiled Jinja-like template engine for Rust. For this release, @Kijewski contributed most of the changes -- @vallentin and @djc are the other team members. This releases comes with integrations for Actix-Web 4, Axum 0.6, Gotham 0.7, hyper 0.14, Tide 0.16 and Warp 0.3. We removed our Iron integration, since this framework no longer seems to be actively maintained.
suppress_whitespace
config option (#664, thanks to @GuillaumeGomez)minimize
config for whitespace
and add handling of ~
in the parser (#673, thanks to @GuillaumeGomez){% match %}
(#616)Display
(#654){% endmacro name %}
(#681, thanks to @Eijebong)_parent
field (#613)ext
argument in integrations (#632)capitalize
filter Unicode-aware (#652, thanks to @Kl4rry)#[template]
attribute is used exactly once (#603)panic!()
in loop.cycle([])
(#617)std::error::Error::source()
(#655)unsafe
code from askama_escape (#665)&str
instead of &[u8]
(#541)impl From<T: Template> for hyper::Body
(#776, thanks to @valkum)After almost 18 months of development, I'm happy to finally announce the 0.11.0 release of Askama, the type-safe, compiled Jinja-like template engine for Rust. Importantly, during this release cycles two new members joined the Askama team (consisting of just @djc at the start of this release): @vallentin and @Kijewski, who both contributed many well-designed improvements to this release. Contributors added integrations for the Axum and Tide web frameworks to our existing set of integrations for Rocket, Actix-Web, Warp and Gotham.
Perhaps the most visible change in this release is the redefined Template
trait which now has a DynTemplate
counterpart rather than the SizedTemplate
used in the previous release (see #579). That said, the template language itself has grown a number of helpful features (as detailed below), while the code generator can now avoid many compilation issues due to better heuristics. We also improved whitespace handling to be more correct, and made several dependencies optional such that using default-features = false
on any of the Askama crates should minimize dependencies if so desired.
Changes:
compile_error!()
(#373, thanks to @msrd0 for improving this in #374)::
(#393)Bug fixes:
template
attributes (#549)Template language:
let
and for
(#506)let
and for
(#509)loop.cycle()
expressions (#517)for
-else
blocks (#518)break
and continue
blocks (#519)raw
blocks (#546)set
alias for let
blocks (#402)Filters:
urlencode
filter to be usable for URL segments, add urlencode_path
(#384, thanks to @JakubValtar)paragraphbreaks
filter (#467, thanks to @mbuscemi)format
filter that swaps the first two arguments (#345, thanks to @couchand)escape
filter (#560)info_f64
and into_isize
filters to take references (#359, thanks to @yshui)Integrations:
Thanks go to @freddyb, @edg-l, @BafDyce, @xfix, @mkj, @robjtede, @technic, @JakeChampion, @SamJakob, @jplatte, @Restioson for their contributions, too.
After 5 months of development, I'm happy to announce the availability of version 0.10 of Askama, the type-safe, compiled Jinja-like template engine for Rust. The major (breaking) change in this release is that the framework integrations, which were previously included in the main crate behind feature flags, have now been moved into 4 separate crates; a new integration with the warp web framework is also shipped in a separate askama_warp crate. If you use an integration, you should now only depend on the integration crate, which re-exports content from the askama crate as well as any integration symbols. Finally, @cetra3 has created a book which should make navigating the documentation much better.
Upgrade notes:
Other changes:
block
s to be nested inside if
, for
and match
blocks (#336)urlencode
filter (#305, thanks to @jxs)truncate
filter (#296, thanks to @danloh)Thanks to @paolobarbolini, @brunobell, @cipriancraciun, @kyrias, @jeromegn, @NilsIrl and @DusterTheFirst for additional improvements.
After 11 months of development, I'm happy to announce the availability of version 0.9 of Askama, the type-safe, compiled Jinja-like template engine for Rust. This has been a long release cycle; mostly I've spent quite a bit of time trying to figure out problems with how to manage Askama's built-in integrations. In the end, 0.9.0 shipped with the integrations problems unsolved, but they were solved shortly thereafter.
Upgrade notes:
size_hint()
method to a separate trait (#270, thanks to @jbg)Other changes:
{% raw %}
blocks (#231, thanks to @fokinpv)self
as a variable (fixes #207)Template
types (#218, thanks to @victe)Thanks to @kazimuth and @bardiharborow for additional internal improvements.
After 3 months of development, I'm happy to announce the availability of version 0.8 of Askama, the type-safe, compiled Jinja-like template engine for Rust -- all the more so because it has taken me way too long to push out this release due to an exceedingly busy period in my personal life.
Askama 0.8 is up to 2 times as fast as 0.7.2, thanks to performance improvements contributed by @botika and @yossyJ. For comparisons to other template engines, please look at the template benchmarks repo. The largest feature this time around is the newly added support for pluggable escape engines and formats. By adding just a few lines to the askama.toml
configuration file and writing a simple implementation of the Escaper
trait, Askama can use custom code for escaping, such as for different formats (LateX or shell) or with even more optimized performance (using SIMD).
Upgrade notes:
Template::extension()
is now a static method (#127, thanks to @ubnt-intrepid)_parent
field is now deprecated (thanks to @botika)Other changes:
into_response()
method for actix-web users (#205, thanks to @ZizhengTai )let
and for
blocks (#187, thanks to @yossyJ)yaml
filter (#192)indent
filter (#131, thanks to @casey)isize
and f64
filters (#146, thanks to @tizgafa)filesizeformat
filter (#161, thanks to @tizgafa)loop.last
variable (#194, thanks to @yossyJ)Template
directly (#147, thanks to @ubnt-intrepid)self
in expressions (#207)stderr
instead of stdout
{% let %}
blocksAfter 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:
abs
, capitalize
, center
and wordcount
index
)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.
impl
for actix-web Responder
trait (thanks to @ryanmcgrath)Template
users to inspect template extension()
(thanks to @ryanmcgrath)derive(Template)
is no longer restricted to named field struct typesI'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)super()
macro can be used to call parent blocks from inside a blockextends
paths on WindowsFor 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:
Range
expressions (a..b
; see #95)Index
operation (a[b]
; see #95)self
loop.first
variabletruncate
filter (see #95)askama::Error
is now Send + Sync + 'static
Thanks to @Smibu and @dathinab 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!
!
and -
(fixes #83)Fixed a regression introduced in 0.6.2 with interacting filter expressions and statements.