some minor exceptions be rather trivial changes.
- `Environment::source`, `Environment::set_source` and the `Source` type
together with the `source` feature were removed. The replacement is the
new `loader` feature which adds the `add_template_owned` and `set_loader`
APIs. The functionality previously provided by `Source::from_path` is
now available via `path_loader`.
Old:
rust
let mut source = Source::with_loader(|name| ...);
source.add_template("foo", "...").unwrap();
let mut env = Environment::new();
env.set_source(source);
New:
rust
let mut env = Environment::new();
env.set_loader(|name| ...);
env.add_template_owned("foo", "...").unwrap();
Old:
rust
let mut env = Environment::new();
env.set_source(Source::from_path("templates"));
New:
rust
let mut env = Environment::new();
env.set_loader(path_loader("templates"));
- `Template::render_block` and `Template::render_block_to_write` were
replaced with APIs of the same name on the `State` returned by
`Template::eval_to_state` or `Template::render_and_return_state`:
Old:
rust
let rv = tmpl.render_block("name", ctx)?;
New:
rust
let rv = tmpl.eval_to_state(ctx)?.render_block("name")?;
- `Kwargs::from_args` was removed as API as it's no longer necessary since
the `from_args` function now provides the same functionality:
Before:
rust
// just split
let (args, kwargs) = Kwargs::from_args(values);
// split and parse
let (args, kwargs) = Kwargs::from_args(values);
let (a, b): (i32, i32) = from_args(args)?;
After:
rust
// just split
let (args, kwargs): (&[Value], Kwargs) = from_args(values)?;
// split and parse
let (a, b, kwargs): (i32, i32, Kwargs) = from_args(values)?;
- The `testutils` feature and `testutils` module were removed. Instead you
can now directly create an empty `State` and use the methods provided
to invoke filters.
Before:
rust
let env = Environment::new();
let rv = apply_filter(&env, "upper", &["hello world".into()]).unwrap();
After:
rust
let env = Environment::new();
let rv = env.empty_state().apply_filter("upper", &["hello world".into()]).unwrap();
Before:
rust
let env = Environment::new();
let rv = perform_test(&env, "even", &[42.into()]).unwrap();
After:
rust
let env = Environment::new();
let rv = env.empty_state().perform_test("even", &[42.into()]).unwrap();
Before:
rust
let env = Environment::new();
let rv = format(&env, 42.into()).unwrap();
After:
rust
let env = Environment::new();
let rv = env.empty_state().format(42.into()).unwrap();
- `intern` and some APIs that use `Arc<String>` now use `Arc<str>`. This
means that for instance `StructObject::fields` returns `Arc<str>` instead
of `Arc<String>`. All the type conversions that previously accepted
`Arc<String>` now only support `Arc<str>`.
- `State::current_call` was removed without replacement. This information
was unreliably maintained in the engine and caused issues with recursive
calls. If you have a need for this API please reach out on the issue
tracker.
- `Output::is_discarding` was removed without replacement. This is
an implementation detail and was unintentionally exposed. You should not
write code that depends on the internal state of the `Output`.