Hi,
I reworked the vyos.template module to make it cleaner and allow for jinja2 template filters to be added more easily in the future.
Notable things I changed:
- Removed the custom caching of compiled templates. Jinja2 does this itself by default and allows to specify the max number of templates to cache. I set it to 100 for now.
- Pass auto_reload=False to jinja2 environment creation. Without this, jinja2 will check if a once loaded template file has changed upon re-rendering, which I'm pretty sure we don't need because template files never change during the run of a Python process, right?
- Added a register_filter() function which allows registering additional template filters. This is more flexible than hardcoding the filters at environment creation and also allows other modules to register their own specific filters outside of vyos.template.
What do you think of these changes?
PR will follow once this has a task number.
Best regards
Robert