mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 15:25:19 +00:00

Recursive macro calls, direct and indirect, would cause a stackoverflow. This PR lets the macro call handler keep track of the stack of called macros we are currently in, so we can abort with an error message instead of panicking.
42 lines
862 B
Rust
42 lines
862 B
Rust
use rinja::Template;
|
|
|
|
#[derive(Template)]
|
|
#[template(
|
|
source = "
|
|
{% macro one %}{% call one %}{% endmacro %}
|
|
{% call one %}
|
|
",
|
|
ext = "html"
|
|
)]
|
|
struct Direct;
|
|
|
|
#[derive(Template)]
|
|
#[template(
|
|
source = "
|
|
{% macro one %}{% call two %}{% endmacro %}
|
|
{% macro two %}{% call three %}{% endmacro %}
|
|
{% macro three %}{% call four %}{% endmacro %}
|
|
{% macro four %}{% call five %}{% endmacro %}
|
|
{% macro five %}{% call one %}{% endmacro %}
|
|
{% call one %}
|
|
",
|
|
ext = "html"
|
|
)]
|
|
struct Indirect;
|
|
|
|
#[derive(Template)]
|
|
#[template(
|
|
source = r#"
|
|
{% import "macro-recursion-1.html" as next %}
|
|
{% macro some_macro %}
|
|
{% call next::some_macro %}
|
|
{% endmacro %}
|
|
{% call some_macro %}
|
|
"#,
|
|
ext = "html"
|
|
)]
|
|
struct AcrossImports;
|
|
|
|
fn main() {
|
|
}
|