Keats / tera2

37 stars 5 forks source link

Add the 'embed' tag like in PebbleTemplate / Twig #26

Closed davy-claisse closed 8 months ago

davy-claisse commented 9 months ago

The embed tag is not part of Jinja2 or Django but originally part of Twig, which is a derived form of both.

The goal of this tag is to get the ability to pass parameters to the embedded template by using the with keyword, for instance:

We declared the following template in the file person.tera.

Hello {{ name }}!

The embed tag allows us to use it like this (without getting information from Tera Context):

{% embed "person.tera" with { "name" : "World" } %}
{% endembed %}

I can give two good documentations of this tag:

Keats commented 9 months ago

Isn't that the same as include with specifying the context in Jinja2? Either way, Tera prefers using macros than includes so that is not going to be added