tera
tera copied to clipboard
Unable to concatenate in extends template name
We can't concatenate in extends template name.
The following code doesn't work.
{% extends variable ~ "my_template" %}
And this error is thrown:
Template '<template name>' not found
Full example here (rust code):
use tera::Tera;
let mut context = tera::Context::new();
context.insert("MY_VARIABLE", "value");
let mut tera = Tera::default();
tera.add_raw_template(
"value_template_1",
r#"block: {% block number %}1{% endblock %}"#,
);
tera.add_raw_template(
"template_2",
r#"{% extends MY_VARIABLE ~ "template_1" %}
{% block number %}2{% endblock %}"#,
);
let out = match tera.render("template_2", &context) {
Ok(content) => content,
Err(error) => {
eprintln!("{}", error);
return;
}
};
println!("{}", out);
This is not supported, only plain strings are allowed (eg {% extends "my_template" %}) so we can rule out inheritance errors at compile time.
Did you plan to support this feature in a further release?
No