Skip to content

Commit

Permalink
fix: disable partial indent with leading ~
Browse files Browse the repository at this point in the history
  • Loading branch information
mkantor committed Jul 16, 2022
1 parent ac5bd3c commit 32bc309
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/partial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
);
Expand Down

0 comments on commit 32bc309

Please sign in to comment.