tera
tera copied to clipboard
indent filter indents whitespace-only lines when blank=false
The indent filter now indents whitespace-only lines even when blank is false. The docs say blank controls "blank/whitespace lines", and Tera 1 skipped them (!line.trim_start().is_empty()), but on master the check is !line.is_empty():
let mut ctx = tera::Context::new();
ctx.insert("s", "a\n \nb");
let out = tera::Tera::one_off("{{ s | indent }}", &ctx, false).unwrap();
assert_eq!(out, "a\n \n b"); // got "a\n \n b"
So a line that only has trailing spaces gets 4 more, which is noticeable when indenting generated YAML/code blocks. Empty lines are still skipped correctly.
Tested on master (ad95994). If this is unintended, the fix would be to use line.trim_start().is_empty() again plus a snapshot case; happy to send a PR.