Releases: djc/askama
0.12.0
0.12.0
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.
Features
- Add markdown filter (#622, #641)
- Add
suppress_whitespace
config option (#664, thanks to @GuillaumeGomez) - Add
minimize
config forwhitespace
and add handling of~
in the parser (#673, thanks to @GuillaumeGomez) - Implement basic hyper integration (#706)
- Determine Content-Type at compile time (#594)
- Parse tuple expressions (#608)
- Allow comments in
{% match %}
(#616) - Expose the fact that templates implement
Display
(#654) - Allow
{% endmacro name %}
(#681, thanks to @Eijebong) - Enable tracking of the offending span of an error (#628)
Removed
- Remove support for deprecated
_parent
field (#613) - Remove
ext
argument in integrations (#632) - Removed Iron integration (#595)
Fixes
- Make
capitalize
filter Unicode-aware (#652, thanks to @Kl4rry) - Fail to parse if keyword is not longest identifier (#742)
- Fix invalid check (#678, thanks to @GuillaumeGomez)
- Fully qualify more paths in generated code (#601)
- Make sure
#[template]
attribute is used exactly once (#603) - Fix json/yaml feature forwarding (#610, thanks to @jannik4)
- Remove
panic!()
inloop.cycle([])
(#617)
Documentation
- Document macro import syntax (#691, thanks to @ojacobson)
- Fix minor issues in escape documentation (#734, thanks to @AndrolGenhald)
- Extend documentation for (#744, thanks to @saona-raimundo)
Internal improvements
- Unify handling of calls (#614)
- Optimize parsing of ranges (#597)
- Remove unneeded external dependencies (630)
- Move all template creation into askama_shared (#647)
- Implement
std::error::Error::source()
(#655) - Move features into derive crate (#662, thanks to @genusistimelord)
- Remove
unsafe
code from askama_escape (#665) - Expose features in integration crates (#688)
- Add caching action to shrink CI times (#698, thanks to @ludicast)
- Skip caching calls (#668)
- Split contents of askama_shared crate into other crates (#677)
- Parse
&str
instead of&[u8]
(#541) - Move code generation into askama_derive (#687)
- Refactor parser (#772)
- Add derive for
impl From<T: Template> for hyper::Body
(#776, thanks to @valkum) - Replace toml_edit with basic-toml (#780)
0.11.0
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:
- Use a separate trait for object safety (#579)
- Allow whitespace in expressions (#327, thanks to @cipriancraciun)
- Add support for shadowing variables (#411)
- Change extension values to ignore common Jinja extensions (#458)
- Disable default features for askama_shared in askama_derive (#344, thanks to @JohnTitor)
- Disable Askama's default features in integration crates (#409, thanks to @Randati)
- Upgrade to nom 7 (#530; nom 6 was done in #372)
- Improve error messages using cuts (#513)
- Improve error messages using
compile_error!()
(#373, thanks to @msrd0 for improving this in #374) - Allow paths to start with
::
(#393) - Improve template loop generation (#401)
- Remove implicit borrowing of literals, calls and more (#423)
- Pass all-uppercase variables through as constants (#433)
- Enable no_std support in askama_escape (#436, thanks to @Nemo157)
- Use raw identifiers for identifiers which collide with Rust keywords (#476, thanks to @SciStarter)
- Rework implicit borrowing to be more relaxed (#396, thanks to @msrd0 for adding tests in #379)
- Improve if-statement generation to avoid issues with implicit borrows (#392)
Bug fixes:
- Fix whitespace issues in match blocks (#399)
- Fix path parser to account for single identifier type names (#453)
- Fix support for raw method identifiers (#548, thanks to @kellytk)
- Fix code generation for macro calls that store args in variables (#499, thanks to @rfk)
- Fix loop generation when accessing field (#500)
- Fix whitespace handling in if-blocks (#394)
- Fix implicit borrow of expressions (#390)
- Avoid hanging the build due to template recursion (#539, thanks to @grv07)
- Avoid parsing non-
template
attributes (#549)
Template language:
- Implement nested tuple destructuring in
let
andfor
(#506) - Implement struct destructuring in
let
andfor
(#509) - Add support for
loop.cycle()
expressions (#517) - Add support for
for
-else
blocks (#518) - Add support for
break
andcontinue
blocks (#519) - Allow whitespace trimming in
raw
blocks (#546) - Add
set
alias forlet
blocks (#402) - Add support for parsing nested comments (#408)
- Fix parsing precedence and associativity (#391, #426)
Filters:
- Stop escaping forward slashes (#486, thanks to @alexwennerberg)
- Fix
urlencode
filter to be usable for URL segments, addurlencode_path
(#384, thanks to @JakubValtar) - Add new
paragraphbreaks
filter (#467, thanks to @mbuscemi) - Add
format
filter that swaps the first two arguments (#345, thanks to @couchand) - Add support for optional escaper argument for
escape
filter (#560) - Change
info_f64
andinto_isize
filters to take references (#359, thanks to @yshui) - Update book to document all filters (#429, #432)
Integrations:
- Removed the Iron integration (#527)
- Add Tide integration (#347, thanks to @jbr)
- Add Axum integration (#563, thanks to @malyn)
- Upgrade Gotham integration to Gotham 0.7 (#557)
- Upgrade Actix-Web integration to Actix-Web 3 (#356), with support for v4 supported on main thanks to @pashinin, @jaw-sh
- Upgrade Warp integration to warp 0.3 (#437, thanks to @paolobarbolini)
- Preliminary support for Rocket 0.5 (#495, thanks to @shritesh and @flo-l; unreleased for now)
Thanks go to @freddyb, @edg-l, @BafDyce, @xfix, @mkj, @robjtede, @technic, @JakeChampion, @SamJakob, @jplatte, @Restioson for their contributions, too.
0.10.0
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:
- Move integration code into askama_actix, askama_gotham, askama_iron and askama_rocket crates
- Update Gotham integration to version 0.4
Other changes:
- Move documentation into a new book (#332, thanks to @Cetra)
- Add integration for the warp web framework, as an askama_warp crate (#290, thanks to @aeons)
- Allow
block
s to be nested insideif
,for
andmatch
blocks (#336) - Support for function calls (#304, thanks to @Senzaki)
- Add
urlencode
filter (#305, thanks to @jxs) - Disable default features in many dependencies to limit the size of the transitive dependency set
- Fix panic in
truncate
filter (#296, thanks to @danloh)
Thanks to @paolobarbolini, @brunobell, @cipriancraciun, @kyrias, @jeromegn, @NilsIrl and @DusterTheFirst for additional improvements.
0.9.0
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:
- Move no-receiver
size_hint()
method to a separate trait (#270, thanks to @jbg) - Upgrade Actix-Web integration to Actix-Web 2.0 (#286, thanks to @DCjanus)
- Default Actix-Web and Gotham integrations to UTF-8 (#219, thanks to @spease)
Other changes:
- Add basic support for
{% raw %}
blocks (#231, thanks to @FokinPV) - Allow referencing
self
as a variable (fixes #207) - Add support for boolean literals (#265, thanks to @davebrent)
- Add support for character literals (#283, thanks to @siiptuo)
- Support escaping in string literals (#287, thanks to @siiptuo)
- Improve interface for askama_escape (#243, thanks to @quadrupleslap)
- Allow Rust macro calls in more places (#226)
- Fix a regression in partial inheritance (#224)
- Improvements to the Actix-Web integration (#223, thanks to @DoumanAsh)
- Clarify documentation on filter precedence (#230, thanks to @notsimon)
- Add documentation on how to deal with recursive data types (#235, thanks to @drahnr)
- Add documentation on nesting
Template
types (#218, thanks to @victe) - Improve documentation for Actix-Web and Gotham integrations (#250, thanks to @bardiharborow)
- Upgrade to nom 5 and non-macro parser combinators
- Upgrade to syn/quote/proc_macro2 version 1.0
Thanks to @kazimuth and @bardiharborow for additional internal improvements.
0.8.0
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:
- The use of build scripts is no longer needed and has been deprecated (#199, thanks to @de-vri-es)
- Upgraded the Rocket integration to Rocket 0.4
Template::extension()
is now a static method (#127, thanks to @ubnt-intrepid)- Use of the
_parent
field is now deprecated (thanks to @botika)
Other changes:
- Upgraded the Rocket integration to Rocket 0.4
- Added optional support for Gotham integration (#177, thanks to @rakenodiax)
- Added an
into_response()
method for actix-web users (#205, thanks to @zizhengtai ) - Add support for tuple destructuring in
let
andfor
blocks (#187, thanks to @YossyJ) - Added optional
yaml
filter (#192) - Added an
indent
filter (#131, thanks to @casey) - Added
isize
andf64
filters (#146, thanks to @tizgafa) - Added a
filesizeformat
filter (#161, thanks to @tizgafa) - Added support for the
loop.last
variable (#194, thanks to @YossyJ) - Allow matching enum struct variants (#182, thanks to @mcarton)
- Allow templates to work without importing
Template
directly (#147, thanks to @ubnt-intrepid) - Allow referencing
self
in expressions (#207) - Fixed problems with unescaped expressions (#107 and #132)
- Fixed off-by-one error in escaping function (#138, thanks to @benjunmun)
- Send debug output to
stderr
instead ofstdout
- Document assignment using
{% let %}
blocks
0.7.2
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
andwordcount
- 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
0.7.1
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-webResponder
trait (thanks to @ryanmcgrath) - Add linebreaks and linebreaksbr filters (thanks to @Aaronepower)
- Allow
Template
users to inspect templateextension()
(thanks to @ryanmcgrath) derive(Template)
is no longer restricted to named field struct types
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 nowSend + 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 @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!