mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-30 22:41:13 +00:00
Add unit-test for #507
This commit is contained in:
parent
89c4488b66
commit
19c685b51a
12
testing/templates/macro-with-caller.html
Normal file
12
testing/templates/macro-with-caller.html
Normal file
@ -0,0 +1,12 @@
|
||||
{%- macro outer() -%}
|
||||
<div>{{caller()}}</div>
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro inner() -%}
|
||||
content
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro intermediate() -%}
|
||||
intermediate
|
||||
{%- call inner() -%}{%- endcall -%}
|
||||
{%- endmacro -%}
|
@ -91,6 +91,24 @@ fn test_include_in_macro_block() {
|
||||
assert_eq!(x.render().unwrap(), "foo.html");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_macro_caller_context_is_declaration_site() {
|
||||
#[derive(Template)]
|
||||
#[template(
|
||||
ext = "html",
|
||||
source = r#"
|
||||
{%- import "macro-with-caller.html" as parentscope -%}
|
||||
{%- call parentscope::outer() -%}
|
||||
{%- call parentscope::intermediate() -%}{%- endcall -%}
|
||||
{%- endcall -%}
|
||||
"#
|
||||
)]
|
||||
struct CallsiteContextIsDeclarationSiteTemplate {}
|
||||
|
||||
let t = CallsiteContextIsDeclarationSiteTemplate {};
|
||||
assert_eq!(t.render().unwrap(), "<div>intermediatecontent</div>");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn str_cmp() {
|
||||
#[derive(Template)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user