I've been using the newly added support for set_lstrip_blocks. Thank you for that! I've noticed, though, that i think it is also stripping leading spaces from expressions -- {{ }}. Those aren't blocks, right? If an expression is positioned with leading whitespace in the file, it should stay that way, I think.
use minijinja::{context, path_loader, Environment};
fn main() {
let mut env = Environment::new();
env.set_trim_blocks(true);
env.set_lstrip_blocks(true);
env.set_loader(path_loader("."));
let tmpl = env.get_template("tmpl.tmp").unwrap();
println!(
"{}",
tmpl.render(context! {things => vec!["one", "two"]})
.unwrap()
)
}
and get this output:
$ cargo run --bin testtmpl
Compiling rules v0.1.0 (/Users/kylederr/Code/perpetualsystems/simba/rules)
Finished dev [unoptimized + debuginfo] target(s) in 0.17s
Running `/Users/kylederr/Code/perpetualsystems/simba/target/debug/testtmpl`
one
two
(note they are not indented)
Additional helpful information:
Version of minijinja: 1.0.20
Version of rustc: rustc 1.76.0 (07dca489a 2024-02-04)
Description
I've been using the newly added support for set_lstrip_blocks. Thank you for that! I've noticed, though, that i think it is also stripping leading spaces from expressions -- {{ }}. Those aren't blocks, right? If an expression is positioned with leading whitespace in the file, it should stay that way, I think.
Here's the way it works in python:
Reproduction steps
Do the above, in rust:
and get this output:
(note they are not indented)
Additional helpful information:
What did you expect
For the blocks to be indented, as per above.