Bug 38723

Summary: Move widely used TT plugins to LOAD_PLUGINS
Product: Koha Reporter: Martin Renvoize (ashimema) <martin.renvoize>
Component: TemplatesAssignee: Martin Renvoize (ashimema) <martin.renvoize>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: baptiste.wojtkowski, david, dcook, fridolin.somers, jonathan.druart, julian.maurice, katrin.fischer, kyle, m.de.rooy, martin.renvoize, nick, oleonard, phil, testopia, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 37634    
Bug Blocks:    
Attachments: Bug 38723: Add LOAD_PLUGINS to Template tooling
Bug 38723: Remove [% USE Koha|Asset|raw %] from all templates
Bug 38723: POC LOAD_FILTERS for raw
Bug 38723: POC LOAD_FILTERS for raw
Bug 38723: WIP Fix valid-templates.t

Description Martin Renvoize (ashimema) 2024-12-17 09:10:26 UTC
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.
Comment 1 Martin Renvoize (ashimema) 2024-12-17 10:15:58 UTC
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.
Comment 2 Martin Renvoize (ashimema) 2024-12-17 10:16:02 UTC
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.
Comment 3 Martin Renvoize (ashimema) 2024-12-17 10:16:47 UTC
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.
Comment 4 Julian Maurice 2024-12-17 10:30:01 UTC
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 ?
Comment 5 Jonathan Druart 2024-12-17 10:31:45 UTC
Created attachment 175604 [details] [review]
Bug 38723: POC LOAD_FILTERS for raw
Comment 6 Jonathan Druart 2024-12-17 10:46:24 UTC
Created attachment 175605 [details] [review]
Bug 38723: POC LOAD_FILTERS for raw
Comment 7 Martin Renvoize (ashimema) 2024-12-17 11:59:00 UTC
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
Comment 8 Fridolin Somers 2024-12-23 13:49:46 UTC
Looks great.

Does this impact notices with TT syntax ?