- Replace unmaintained unic-segment dependency
- Support parenthesis in if statements
- Allow escaped newline and tab join separator
- Minimum supported Rust version (MSRV) is now 1.63 due to transitive dependencies.
- Update crates.io metadata for the website
- Revert change to glob path to not error if the path doesn't exist
- Allow macro definition in renderable template
- Fix panic on invalid globs to Tera::new
- Add
absfilter - Add
indentfilter - Deprecate
get_json_pointerin favour ofdotted_pointer, a faster alternative - Always canonicalize glob paths passed to Tera to workaround a globwalk bug
- Handle apostrophes in title case filter
- Some performance improvement
- Make
get_randomuse isize instead of i32 and bad error message - Fix variables lookup when the evaluated key has a
.or quotes - Fix changed output of f64 from serde_json 1.0.85
- Fix bug where operands in
inoperation were escaped before comparison - Force chrono dep to be 0.4.20 minimum
- Better support for parenthesis in expression
- Add a feature just for the urlencode builtin
- Fix bug in slice filter if start >= end
- Allow supplying a timezone to a timestamp for the date filter
- Add
defaultparameter togetfilter Tera::extendnow also copies over function- Remove the new Context-local Tera function support, it was an accidental breaking change and will be added in v2 in some ways instead
- Ensure
Contextstays valid in Sync+Send, fixing an issue introduced in 1.13. 1.113 will be yanked.
- Add
defaultparameter togetfilter Tera::extendnow also copies over function- Add Context-local Tera functions
- Remove unused feature of chrono
- Remove unwanted bloat in crate from accidental WASM files
- Add
spacelessfilter from Django
- Allow iterating on strings with
for
- Add
Tera::get_template_names
- Add
Context::remove
- Add
linebreaksbrfilter from Django - Allow dots in context object key names
- Fix parsing of filter arguments separated by whitespaces
- Allow rendering to
std::io::Write - Follow symlinks in glob
- Allow including lists of templates
- Comment tags can now use whitespace control
- Fix date filter sometimes panicking with some format input
- Allow multiline function kwargs with trailing comma
- Add
Context::try_insert
- Add the concept of safe functions and filters
- Allow negative index on
slicefilter
- Add
Context::getandContext::contains_key
- Fix
rawtag swallowing all whitespace at beginning and end - Make batch template sources generic
- Automatically add function/test/filter function name to their error message
- Add a
urlencode_strictfilter - Add more array literals feature in templates
- Make
filterfilter value argument optional
- Add
trim_start,trim_end,trim_start_matchesandtrim_end_matchesfilters - Allow blocks in filter sections
- Add Tera::render_str, like Tera::one_off but can use an existing Tera instance
- Length filter now errors for things other than array, objects and strings. The fact that it was returning 0 before for other types was something that should have been fixed before 1.0 but got forgotten and was considered a bug.
- Fix filter sections not keeping whitespaces
- The filesizeformat filter now takes a usize instead of a i64: no changes to behaviour
- Now requires Rust 1.34
- Removed error-chain errors and added rich Error enum instead
- Filter, Tester and Function are now traits and now take borrowed values instead of owned
- Updated for 2018 edition
- Require macros import to be at the top of the files along with
extendsas it is fairly cheap and the code already only really look there. - Enforce spacing in tags at the parser, before
ifsomethingwas considered ok - Pluralize filter now uses
singularandpluralarguments instead ofsuffix - Add a test for checking whether a variable is an object
- Escaping now happens before inserting the final result of an expression: no need anymore to add
| safeeverywhere, only at the last position - Remove
safeargument of the urlencode filter,/is still escaped by default - The
compile_templates!macro has been removed
- Tests can now use
value is not definedorder for negation (#308) - Add
nthfilter to get the nth value in an array - You can now use glob patterns in
Tera::new defaultfilter now works on Null values- Literal numbers in template overflowing i64/f64 will now be an error instead of panicking
- Allow arrays as test arguments
- Add the
inoperator to check if a left operand is contained in a right one. Also supports negation asnot in - Add
Context::from_valueto instantiate aContextfrom a serde_jsonValue - Add
Context::from_serializeto instantiate aContextfrom something that implSerialize - Make tests helper fns
number_args_allowed,value_definedandextract_stringpublic - Add
elseclause to for loops - Filters are now evaluated when checking if/elif conditions
- Allow
{{-and-}}for whitespace management - Add
xml_escapefilter - Grave accent is no longer escaped in HTML, it is not really needed anymore
- Add a
builtinsdefault feature that gate all filters/functions requiring additional dependencies - Add
uniqueandmapfilter - Add a
timezoneattribute to thedatefilter - Add a
get_randomfunction to get a random number in a range - Add a
get_envfunction to get the value of an environment variable
- Fix bugs in
filterandgetfilters
- Allow function calls in math expressions
- Allow string concatenation to start with a number
- Allow function calls in string concatenations
- Add a
concatfilter to concat arrays or push an element to an array
- Allow concatenation of strings and numbers
- Clear local context on each forloop iteration
- Fix variable lookup with
.that was completely wrong - Now requires Rust 1.26 because of some dependencies update
- Fix
set/set_globalnot working correctly in macros - Deprecate
register_global_functionforregister_function
- Remove invalid
unreachable!call causing panic in some combination or for loop and specific filters - Fix macros loading in parent templates and using them in child ones
- Fix macros loading other macros not working when called in inheritance
- Mark
Context::addas deprecated and do not display it in the docs anymore (aka TIL thedeprecatedattribute) - Fix
__tera_contextnot getting all the available context (set,forloopetc) - Better error message when variable indexing fails
- Remove stray println
- Add
as_strfilter - Way fewer allocations and significant speedup (2-5x) for templates with large objects/loops
- Checks that all macro files are accounted for at compile time and errors if it's not the case
filterfilter was not properly registered (╯°□°)╯︵ ┻━┻
truncatefilter now works correctly on multichar graphemes
- Add a
throwglobal function to fail rendering from inside a template
- Add a
matchingtester - Register
nowglobal function so it is available - Update
error-chain
- Add
TrueandFalseas boolean values to match Python - Allow user to define their own escape function, if you want to generate JSON for example
- Add
endargument to thetruncatefilter to override the default ellipsis - Add a
group_byfilter - Add a
filterfilter - Add the
~operator to concatenate strings - Add a
nowglobal function to get local and UTC datetimes - Add feature to enable the
preserve_orderfeature of serde_json - Less confusing behaviour with math arithmetics
- Add array literal instantiation from inside Tera for set, set_global, kwargs and for loop container
- Fix panic on truncate filter
- Add
breakandcontinueto forloops - Fix strings delimited by single quote and backtick not removing the delimiters
- Re-export
serde_json::Numberas well
- Re-export
serde_json::Mapas well - You can now access inside a variable using index notation:
{{ arr[0] }},{{ arr[idx] }}etc thanks to @bootandy - Add
Context::insertidentical toContext::addto mirror Rust HashMap/BTreeMap syntax
- Add a
slicefilter for arrays - Fix macro files importing other macro files not loading properly
- Fix forloop container being allowed logic expressions
- Much improved parsing error messages
- Fix regression when including templates that import macros
- Fix
pluralizefilter for real this time!
- Fix regression with expressions in comparisons
- Tests parentheses are now mandatory if there are arguments (
divisibleby 2->divisibleby(2)) - Tests can be only used on variables now, not on expressions
- Escaping happens immediately now instead of waiting for the filters to be called, unless
safeis first. If you want the old behaviour you will need to start the a chain of filters with| safeas the first one
- Tests, global functions calls and macro calls are now expressions and can be combined like so:
if x is divisibleby(2) and x > 10 - Add default arguments for macro arguments
- Add whitespace management similar to Liquid and Jinja2
- Add parentheses to expressions to remove ambiguities
- Block & macro end tag name are no longer mandatory and it doesn't error on mismatched names between the start and end tag anymore
- Filters can now be applied to expressions
- Add modulo operator
%for math expressions - Allow comment tags before the extend tag
- Make
NaiveDateTimework with thedatefilter pluralizefilter now returns the plural suffix for 0 thing as it's apparently what English does- Add a
set_globaltag that allows you to set something in the global context: meant to be used in forloops where the normalsetwould put the value into the loop context - Add
starting_with,ending_withandcontainingtests - Add
json_encode,defaultandsortfilters - Strings can now also be contained in backticks and single quotes in templates
- Add
Tera::parsefor some niche use-cases
- Handle path to templates starting with "./"
- Fix loop and macro context overlaps
- Fix variables being escaped when given to
setor as arguments to filters/macros/global fns
- Update chrono
- Fix not being able to use variables starting with
or,andandnot - Fix
<=and>=not being recognised properly - Fix if/elif conditions falling through: only the first valid one will be rendered
- Handle NaN results in
{% set %}instead of panicking - Allow math node on if/elif conditions & fix f64 truthiness
- Fix not being able to call global functions without arguments
- Fix multiple inheritance not rendering blocks as expected for nested blocks
- Allow filters on key/value for loop containers
- Fix bug with
{% set %}in forloops
- Add
SendtoGlobalFnreturn type
- Add global functions, see README
- Add set tag, see README
- Add get filter
- Fix bug with section filter swallowing all content after the end tag
- Allow whitespace in function args
- Fix bug with variable in loop using starting with the container name (#165)
- Allow whitespace in macros/filters params
- Update Serde to 1.0.0
- Fix date filter converting everything to UTC
- Fix panic when using filters on forloop container
- Fix bug in Windows where the glob path was not removed correctly
Tera::extendnow also copy filters and testers
- Macro rendering perf improved and general code cleanup thanks to @Peternator7
- Fix bug in parser with floats
- Make
datefilter work with string input inYYYY-MM-DDformat - Big parsing improvement (~20-40%) for projects with macros and inheritance
- Add
Tera::extendto extend another instance of Tera - Add
Tera::full_reloadthat will re-run the glob and parse all templates found. - Make
Tera::add_raw_template{s}andTera::add_template_file{s}part of the public API - Fix location in error message when erroring in a child template
- Remove
value_renderandvalue_one_off, you can now userenderandone_offfor both values and context
- Speed improvements on both parsing and rendering (~20-40% faster)
- Better error message on variable lookup failure in loops
- Can now iterate on maps/struct using the
{% for key, val in my_object %}construct
- Update chrono version
- Make variable block like
{{ "hey" }}render correctly
- Support filter sections
- Fix path prefix trimming on Windows
Tera::add_template->Tera::add_raw_templateTera::add_templates->Tera::add_raw_templates
- Performance improvement thanks to @clarcharr
- Better error message for
value_render. Thanks to @SilverWingedSeraph for the report - Hide
add_raw_templateandadd_raw_templatesfrom docs, they were meant for internal use - Exported macros now use the
$cratevariable, which means you don't need to import anything from Tera to have them working - Expose AST (not covered by semver)
- Add a
Context::extendmethod to merge a context object into another one
- Performance improvements thanks to @wdv4758h
- Correctly register
datefilter and make it work on a RFC3339 string as well thanks to @philwhineray
- Added
Tera::value_one_offto parse and render a single template using a Json value as context
notis now a Tera keyword
- Added
#![deny(missing_docs)]to the crate - Added
Tera::one_offto parse and render a single template - Added
notoperator in conditions to mean falsiness (equivalent to!in Rust) - Remove specific error message when using
||or&& - Improved performances for parsing and rendering (~5-20%)
- Added
precisionarg toroundfilter - Added
datefilter to format a timestamp to a date(time) string
A few breaking changes in this one
- Tera no longer panics when parsing templates, it returns an error instead
- Tester fn signature changes from
fn(&str, Option<Value>, Vec<Value>) -> Result<bool>tofn(Option<Value>, Vec<Value>) -> Result<bool> - Rename
TeraResultexport toResult
- Stabilized
Tera::add_templateandTera::add_templates - Added
compile_templates!macro to try to compile all templates and, in case of errors, print them and exit the process - Much improved error messages
- Add a magical variable
__tera_contextthat will pretty print the current context - More documentation inside the crate itself
- Actually register the
filesizeformat,slugify,addslashes, good thing no one noticed - Add
divisiblebyanditerabletest - Made
try_get_value!macro work outside of Tera
- Remove println! left behind
- Fix macros not being found in child templates
- Export
Valueandto_value(currently from serde-json)
- Add macros
- Add
filesizeformatfilter - Add autoescape
- Add multiple level inheritance
- Add nested blocks
- Add
{{ super() }}
Thanks to @SergioBenitez and @yonran for the help!
- Fix regression when using variables in forloops + add test for it
- Change signature of tests functions (BREAKING CHANGE)
- Add more tests:
undefined,odd,even,numberandstring - Add
includedirective to include another file - Indexed array/tuple access using the
.xwherexis an integer
Thanks to @SergioBenitez and @andrelmartins for the contributions!
- Added filters, see README for current list
- Added tests, only
definedfor now
Thanks to @SergioBenitez, @orhanbalci, @foophoof and @Peternator7 for the contribution!
- Completely new parser
- Expose TeraError