3 ms·
> Jinja has an extension interface and I regret adding it. I much rather have people just expose functions to the templates. So, like Ruby's ERB, where you're
by derefr 11y ago
> Jinja has an extension interface and I regret adding it. I much rather have people just expose functions to the templates.
So, like Ruby's ERB, where you're passing a lexical binding? Or is that going a bit too far? (It's always felt a bit "magic" to me, but—imagining a version of ERB that compiled its templates to modules—the magic would basically have to be discarded at compile-time and turned into regular hash-lookups in order to get something with a sane runtime API anyway. So it'd be the "funny macro" kind of magic rather than the "bunch of runtime introspection" kind of magic.)
- Nullabillity 11y agoFor the record, that's how Play's Twirl templates work. Templates are compiled (at compile time) to plain Scala singletons with an entry point method that builds the output.