Bug 38723 - Move widely used TT plugins to LOAD_PLUGINS
Summary: Move widely used TT plugins to LOAD_PLUGINS
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Martin Renvoize (ashimema)
QA Contact: Testopia
URL:
Keywords:
Depends on: 37634
Blocks:
  Show dependency treegraph
 
Reported: 2024-12-17 09:10 UTC by Martin Renvoize (ashimema)
Modified: 2024-12-24 01:13 UTC (History)
15 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 38723: Add LOAD_PLUGINS to Template tooling (4.05 KB, patch)
2024-12-17 10:15 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38723: Remove [% USE Koha|Asset|raw %] from all templates (337.11 KB, patch)
2024-12-17 10:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38723: POC LOAD_FILTERS for raw (1.75 KB, patch)
2024-12-17 10:31 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38723: POC LOAD_FILTERS for raw (1.41 KB, patch)
2024-12-17 10:46 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38723: WIP Fix valid-templates.t (1.66 KB, patch)
2024-12-17 11:59 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 ?