Skip to content

Commit

Permalink
test: add test case for partial indent issue #482
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 committed Dec 31, 2021
1 parent 6b518e8 commit 9ae9f24
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/partial_indent.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use handlebars::*;
use serde_json::json;

#[test]
fn test_partial_indent() {
let outer = r#" {{> inner inner_solo}}
{{#each inners}}
{{> inner}}
{{/each}}
{{#each inners}}
{{> inner}}
{{/each}}
"#;
let inner = r#"name: {{name}}
"#;

let mut hbs = Handlebars::new();

hbs.register_template_string("inner", inner).unwrap();
hbs.register_template_string("outer", outer).unwrap();

let result = hbs
.render(
"outer",
&json!({
"inner_solo": {"name": "inner_solo"},
"inners": [
{"name": "hello"},
{"name": "there"}
]
}),
)
.unwrap();

assert_eq!(
result,
r#" name: inner_solo
name: hello
name: there
name: hello
name: there
"#
);
}
// Rule::partial_expression should not trim new lines by default

0 comments on commit 9ae9f24

Please sign in to comment.