emacs-love / templatel

Jinja inspired template language for Emacs Lisp
https://emacs.love/templatel
GNU General Public License v3.0
54 stars 6 forks source link

Add support for include statement #9

Closed markokocic closed 3 years ago

markokocic commented 3 years ago

While trying to port my old website templates from Cryogenweb selmer to weblorg I found out that templatel is missing ability to include a template inside another template.

I fish to do something like this:

This would allow for better template reusability.

clarete commented 3 years ago

Hi @markokocic thanks for opening an issue for this feature!

I think we have most of this figured out because of how template rendering already works; I think it would mostly only take changes to the syntax to accept a new keyword and to the compiler to spit out the code to render the included template. Sounds like a fun feature to work on as well! 😄

guilhermecomum commented 3 years ago

I'm working on it :)

clarete commented 3 years ago

Thanks to @guilhermecomum's work, we've landed the initial support for include. I'll close this ticket, but please feel free to re-open it or open a new one if anything comes around, @markokocic.

Thank you! 🙇🏾

markokocic commented 3 years ago

Basic include statement works for me.

Btw, is there a way to pass a parameter to the include statement? Something like

{% include "page.html", content=post %}
clarete commented 3 years ago

@markokocic nice! thanks for giving it a try 🙇🏾

hmm, that's an interesting feature. I've been eyeing Jinja's Macros design. I think it'd probably be more powerful than messing with the scope in an include system (that being said, I believe the current implementation of include should see the variables available for the template including it).