Skip to content

Commit

Permalink
(fix) fix partial included on evaluation [#146]
Browse files Browse the repository at this point in the history
Signed-off-by: Ning Sun <sunng@about.me>
  • Loading branch information
sunng87 committed Apr 14, 2017
1 parent db5cc8d commit 765fd2a
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,12 @@ impl Renderable for TemplateElement {
}
}
DirectiveExpression(_) |
DirectiveBlock(_) |
PartialExpression(_) |
PartialBlock(_) => self.eval(registry, rc),
DirectiveBlock(_) => self.eval(registry, rc),
#[cfg(not(feature="partial_legacy"))]
PartialExpression(ref dt) | PartialBlock(ref dt) => {
Directive::from_template(dt, registry, rc)
.and_then(|di| partial::expand_partial(&di, registry, rc))
}
_ => Ok(()),
}
}
Expand All @@ -710,11 +713,6 @@ impl Evaluable for TemplateElement {
}
})
}
#[cfg(not(feature="partial_legacy"))]
PartialExpression(ref dt) | PartialBlock(ref dt) => {
Directive::from_template(dt, registry, rc)
.and_then(|di| partial::expand_partial(&di, registry, rc))
}
_ => Ok(()),
}
}
Expand Down Expand Up @@ -907,3 +905,16 @@ fn test_render_error_line_no() {
panic!("Error expected");
}
}

#[test]
#[cfg(not(feature="partial_legacy"))]
fn test_partial_failback_render() {
let mut r = Registry::new();

assert!(r.register_template_string("parent", "<html>{{> layout}}</html>").is_ok());
assert!(r.register_template_string("child", "{{#*inline \"layout\"}}content{{/inline}}{{#> parent}}{{> seg}}{{/parent}}").is_ok());
assert!(r.register_template_string("seg", "1234").is_ok());

let r = r.render("child", &true).expect("should work");
assert_eq!(r, "<html>content</html>");
}

0 comments on commit 765fd2a

Please sign in to comment.