Home Explore Blog CI



tera

2nd chunk of `CHANGELOG.md`
15c694a522028d01541f8d04e1cdc5d7dc11ef12e0caca450000000100000fbe

## 1.4.0 (2020-07-24)

- Add `Context::get` and `Context::contains_key`

## 1.3.1 (2020-06-09)

- Fix `raw` tag swallowing all whitespace at beginning and end
- Make batch template sources generic
- Automatically add function/test/filter function name to their error message

## 1.3.0 (2020-05-16)

- Add a `urlencode_strict` filter
- Add more array literals feature in templates
- Make `filter` filter value argument optional

## 1.2.0 (2020-03-29)

- Add `trim_start`, `trim_end`, `trim_start_matches` and `trim_end_matches` filters
- Allow blocks in filter sections

## 1.1.0 (2020-03-08)

- Add Tera::render_str, like Tera::one_off but can use an existing Tera instance

## 1.0.2 (2020-01-13)

- 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.


## 1.0.1 (2019-12-18)

- Fix filter sections not keeping whitespaces
- The filesizeformat filter now takes a usize instead of a i64: no changes to behaviour

## 1.0.0 (2019-12-07)

### Breaking changes

- 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 `extends` as it is fairly cheap and
the code already only really look there.
- Enforce spacing in tags at the parser, before `ifsomething` was considered ok
- Pluralize filter now uses `singular` and `plural` arguments instead of `suffix`
- 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 `| safe` everywhere,
only at the last position
- Remove `safe` argument of the urlencode filter, `/` is still escaped by default
- The `compile_templates!` macro has been removed

### Others

- Tests can now use `value is not defined` order for negation (https://github.com/Keats/tera/issues/308)
- Add `nth` filter to get the nth value in an array
- You can now use glob patterns in `Tera::new`
- `default` filter 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 `in` operator to check if a left operand is contained in a right one. Also supports negation as `not in`
- Add `Context::from_value` to instantiate a `Context` from a serde_json `Value`
- Add `Context::from_serialize` to instantiate a `Context` from something that impl `Serialize`
- Make tests helper fns `number_args_allowed`, `value_defined` and `extract_string` public
- Add `else` clause to for loops
- Filters are now evaluated when checking if/elif conditions
- Allow `{{-` and `-}}` for whitespace management
- Add `xml_escape` filter
- Grave accent is no longer escaped in HTML, it is not really needed anymore
- Add a `builtins` default feature that gate all filters/functions requiring additional dependencies
- Add `unique` and `map` filter
- Add a `timezone` attribute to the `date` filter
- Add a `get_random` function to get a random number in a range
- Add a `get_env` function to get the value of an environment variable

## 0.11.20 (2018-11-14)

- Fix bugs in `filter` and `get` filters

## 0.11.19 (2018-10-31)

- Allow function calls in math expressions
- Allow string concatenation to start with a number
- Allow function calls in string concatenations
- Add a `concat` filter to concat arrays or push an element to an array

## 0.11.18 (2018-10-16)

- Allow concatenation of strings and numbers

## 0.11.17 (2018-10-09)

- 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

## 0.11.16 (2018-09-12)

- Fix `set`/`set_global` not working correctly in macros
- Deprecate `register_global_function` for `register_function`

Title: Tera Changelog: Versions 1.4.0 to 0.11.16
Summary
This document summarizes the changes made to the Tera templating engine, spanning from version 1.4.0 (July 24, 2020) to version 0.11.16 (September 12, 2018). The changes include the addition of new filters (e.g., `urlencode_strict`, `trim_start`, `trim_end`), functions (e.g., `get_env`, `get_random`), and context methods (`Context::get`, `Context::contains_key`, `Context::from_value`, `Context::from_serialize`). It highlights breaking changes introduced in version 1.0.0, such as requiring Rust 1.34, replacing error-chain errors with a rich Error enum, and updating for the 2018 edition. Bug fixes, performance improvements, and feature additions are also detailed.