Closed DK26 closed 2 years ago
I have read in the documentation that it is possible to somehow dynamically assign an include to a template
You can't include a template with a dynamic name, it has to be a string not an ident.
So just to make sure I understand correctly: It is NOT possible to use a macro to achieve this and the comment in the documentation is out-dated and therefore misleading?
Or, the comment in the docs meant to say something else?
The latter. Context here means variables. You can't do include "blabla.html" with foo = 2
but you can define a macro that takes a foo argument.
The latter. Context here means variables. You can't do
include "blabla.html" with foo = 2
but you can define a macro that takes a foo argument.
Ohhh I see now 🤦♂️. It's about passing down context / variables to an external template.. lol😅
Thank you for your time and patience!
I have read in the documentation that it is possible to somehow dynamically assign an include to a template:
Tera doesn't offer passing a custom context to the include tag. If you want to do that, use macros.
But as much as I digged the docs, I did not find any example or a proper combination to make that work.
I encountered issue #603 but that wasn't helpful neither. Putting a macro with the next value:
Would simply produce an error:
Template '[{{ id }}.html]' not found
.Is there a way to achieve this?