4 ms·
Are there other template library in other languages ( especially in rust or go ) that converts templates in to native language code for execution? Like the way
by iamgopal 5y ago
Are there other template library in other languages ( especially in rust or go ) that converts templates in to native language code for execution? Like the way jinja do.
- giancarlostoro 5y agoIn D, vibe.d does this. It uses a pug like syntax for templates. Edit: They've extracted the library into its own thing called diet-ng https://vibed.org/ https://vibed.org/ https://github.com/rejectedsoftware/diet-ng/ https://github.com/rejectedsoftware/diet-ng/
- denysvitali 5y agoYes, there is pongo2 [0] and my runner (basically a small Go software that runs the template engine) pongo2-runner [1]. I'm not the author of the library (pongo2), but I'm using pongo2-runner to dynamically create config files out of environment variables, with custom logic. Super recommended. [0]: https://github.com/flosch/pongo2 https://github.com/flosch/pongo2 [1]: https://github.com/swisscom/pongo2-runner https://github.com/swisscom/pongo2-runner
- eatonphil 5y agoPongo2 is a tree walking interpreter from everything I see. It does not compile the templates into bytecode or native code before executing/interpreting.
- denysvitali 5y agoOh yes, sorry, misread that. Never mind then!
- conradfr 5y agoTwig, inspired by Jinja2. https://twig.symfony.com/ https://twig.symfony.com/
- shakna 5y agoMost template languages for Lua generate functions, that will be called with their own environment. Having first-class environments makes that the "obvious" way of doing things. For example, here's a 160LOC one I wrote a while back. [0] [0] https://git.sr.ht/~shakna/lserver/tree/master/item/template.lua https://git.sr.ht/~shakna/lserver/tree/master/item/template....