Whilst QAing bug 37634 it felt silly to me to be adding [% USE Koha %] to so many templates.. there must be a better way. So I added a follow-up.. but then we discussed it on chat and decided we could expand the scope a bit further from 'Koha' to 'Koha', 'Asset' and 'raw' plugins.. the three most commonly called TT plugins in Koha templates. So.. to keep things easy for RMaints, I've opted to move my cleanup patches here.
Created attachment 175601 [details] [review] Bug 38723: Add LOAD_PLUGINS to Template tooling This patch adds the Koha, Asset, and raw TT plugins that are used throughout templates to the LOAD_PLUGINS directive on Template load.. this way we shouldn't need to keep adding them to the top of every TT file and include.
Created attachment 175602 [details] [review] Bug 38723: Remove [% USE Koha|Asset|raw %] from all templates We now load this plugin by default using LOAD_PLUGINS so we no longer need to reference it in a USE statement in every template file.
This doesn't work.. LOAD_PLUGINS doesn't work as I thought at all.. but I'm a bit confused as to how to resolve it right now.
Have you tried NAMESPACE (https://template-toolkit.org/docs/manual/Config.html#section_NAMESPACE) ? It is for constants but maybe a subroutine can be used as the value of a constant ?
Created attachment 175604 [details] [review] Bug 38723: POC LOAD_FILTERS for raw
Created attachment 175605 [details] [review] Bug 38723: POC LOAD_FILTERS for raw
Created attachment 175606 [details] [review] Bug 38723: WIP Fix valid-templates.t I'm not sure why/how this works.. and it doesn't resolve all issues and will need applying to the Template calls in proper Koha and not just the tests too I believe
Looks great. Does this impact notices with TT syntax ?