mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-01 15:00:57 +00:00
bugfix: resolve with macro with call after caller
https://github.com/askama-rs/askama/issues/467 Signed-off-by: Michael Pollind <mpollind@gmail.com>
This commit is contained in:
parent
0e30499f59
commit
df54534ae6
@ -779,7 +779,7 @@ impl<'a> Generator<'a, '_> {
|
||||
})?;
|
||||
self.prepare_ws(ws2);
|
||||
self.seen_callers.pop();
|
||||
self.active_caller = None;
|
||||
self.active_caller = self.seen_callers.last().map(|v| v.0);
|
||||
Ok(size_hint)
|
||||
}
|
||||
|
||||
|
@ -254,6 +254,27 @@ fn test_caller_expr() {
|
||||
assert_eq!(MacroCallerExpr.render().unwrap(), "20 1 35\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_caller_in_macro_call_before_caller() {
|
||||
#[derive(Template)]
|
||||
#[template(
|
||||
source = r#"
|
||||
{%- macro test2() -%}
|
||||
a
|
||||
{{- caller() -}}
|
||||
{%- endmacro -%}
|
||||
{%- macro test() -%}
|
||||
{%- call test2() -%}b{%- endcall -%}
|
||||
{{- caller() -}}
|
||||
{%- endmacro -%}
|
||||
{%- call test() -%}{%- call test2() -%}b{%- endcall -%}{%- endcall -%}
|
||||
"#,
|
||||
ext = "txt"
|
||||
)]
|
||||
struct CallerWithMacro;
|
||||
assert_eq!(CallerWithMacro.render().unwrap(), "abab");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_caller_in_caller() {
|
||||
#[derive(Template)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user