From 32bc309b351bff77027d84a6e0f5d6441d4f205d Mon Sep 17 00:00:00 2001 From: Matt Kantor Date: Sat, 16 Jul 2022 17:04:54 -0400 Subject: [PATCH] fix: disable partial indent with leading ~ --- src/partial.rs | 17 +++++++++++++++++ src/template.rs | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/partial.rs b/src/partial.rs index 04935de5a..fbf24243e 100644 --- a/src/partial.rs +++ b/src/partial.rs @@ -595,6 +595,23 @@ outer third line"#, .unwrap() ); + hb.register_template_string( + "t4", + r#"{{#*inline "thepartial"}} + inner first line + inner second line +{{/inline}} + {{~> thepartial}} +outer third line"#, + ) + .unwrap(); + assert_eq!( + r#" inner first line + inner second line +outer third line"#, + hb.render("t4", &()).unwrap() + ); + let mut hb2 = Registry::new(); hb2.set_prevent_indent(true); diff --git a/src/template.rs b/src/template.rs index 58a978da6..617f47711 100644 --- a/src/template.rs +++ b/src/template.rs @@ -728,7 +728,10 @@ impl Template { // indent for partial expression > let mut indent = None; - if rule == Rule::partial_expression && !options.prevent_indent { + if rule == Rule::partial_expression + && !options.prevent_indent + && !exp.omit_pre_ws + { indent = support::str::find_trailing_whitespace_chars( &source[..span.start()], );