Skip to content

Commit ffd4c33

Browse files
committed
test: add another test case to access data within partial
1 parent 510e02e commit ffd4c33

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/context.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ fn parse_json_visitor<'a, 'reg>(
4545
for path_seg in relative_path {
4646
match path_seg {
4747
PathSeg::Named(the_path) => {
48-
// FIXME: partial block params resolution for 495
49-
// we should not search whole block stack for the
50-
// param, if there is a same name in current block
5148
if let Some((holder, base_path)) = get_in_block_params(block_contexts, the_path) {
5249
with_block_param = Some((holder, base_path));
5350
}

src/partial.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ name: there
500500
fn test_partial_context_issue_495() {
501501
let mut hb = Registry::new();
502502
hb.register_template_string(
503-
"t",
503+
"t1",
504504
r#"{{~#*inline "displayName"~}}
505505
Template:{{name}}
506506
{{/inline}}
@@ -511,17 +511,29 @@ Name:{{name}}
511511
)
512512
.unwrap();
513513

514+
hb.register_template_string(
515+
"t1",
516+
r#"{{~#*inline "displayName"~}}
517+
Template:{{this}}
518+
{{/inline}}
519+
{{#each data as |name|}}
520+
Name:{{name}}
521+
{{>displayName}}
522+
{{/each}}"#,
523+
)
524+
.unwrap();
525+
514526
let data = json!({
515527
"data": ["hudel", "test"]
516528
});
517529

518530
assert_eq!(
519531
r#"Name:hudel
520-
Template:aaaa
532+
Template:hudel
521533
Name:test
522-
Template:aaaa
534+
Template:test
523535
"#,
524-
hb.render("t", &data).unwrap()
536+
hb.render("t1", &data).unwrap()
525537
);
526538
}
527539
}

0 commit comments

Comments
 (0)