[Bug 38723] New: Move widely used TT plugins to LOAD_PLUGINS
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 Bug ID: 38723 Summary: Move widely used TT plugins to LOAD_PLUGINS Change sponsored?: --- Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: minor Priority: P5 - low Component: Templates Assignee: oleonard@myacpl.org Reporter: martin.renvoize@ptfs-europe.com QA Contact: testopia@bugs.koha-community.org CC: baptiste.wojtkowski@biblibre.com, david@davidnind.com, fridolin.somers@biblibre.com, jonathan.druart@gmail.com, katrin.fischer@bsz-bw.de, kyle@bywatersolutions.com, m.de.rooy@rijksmuseum.nl, martin.renvoize@ptfs-europe.com, nick@bywatersolutions.com, oleonard@myacpl.org, testopia@bugs.koha-community.org, tomascohen@gmail.com Depends on: 37634 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. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37634 [Bug 37634] Missing "USE Koha" causes JS errors and missing "Last patron" menu -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 Martin Renvoize (ashimema) <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|oleonard@myacpl.org |martin.renvoize@ptfs-europe | |.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 Martin Renvoize (ashimema) <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|minor |enhancement -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@ptfs-europe.com> --- Created attachment 175601 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=175601&action=edit 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. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@ptfs-europe.com> --- Created attachment 175602 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=175602&action=edit 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. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 Martin Renvoize (ashimema) <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Text to go in the|This fixes the cause of the | release notes|"Last patron" menu not | |displaying on many staff | |interface pages, or | |generating JavaScript | |errors (where | |showLastPatron is enabled). | |(It adds "[% USE Koha %]" | |to templates where it was | |missing. It also removes | |some duplicate USE | |entries.) | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 --- Comment #3 from Martin Renvoize (ashimema) <martin.renvoize@ptfs-europe.com> --- 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. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |julian.maurice@biblibre.com --- Comment #4 from Julian Maurice <julian.maurice@biblibre.com> --- 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 ? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 --- Comment #5 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 175604 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=175604&action=edit Bug 38723: POC LOAD_FILTERS for raw -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #175604|0 |1 is obsolete| | --- Comment #6 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 175605 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=175605&action=edit Bug 38723: POC LOAD_FILTERS for raw -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 --- Comment #7 from Martin Renvoize (ashimema) <martin.renvoize@ptfs-europe.com> --- Created attachment 175606 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=175606&action=edit 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 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 Phil Ringnalda <phil@chetcolibrary.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |phil@chetcolibrary.org -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 --- Comment #8 from Fridolin Somers <fridolin.somers@biblibre.com> --- Looks great. Does this impact notices with TT syntax ? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 Bug 38723 depends on bug 37634, which changed state. Bug 37634 Summary: Missing "USE Koha" causes JS errors and missing "Last patron" menu https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37634 What |Removed |Added ---------------------------------------------------------------------------- Status|Needs documenting |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 --- Comment #9 from David Cook <dcook@prosentient.com.au> --- (In reply to Martin Renvoize (ashimema) from comment #3)
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.
So I've got a couple ideas. 1. Try to use PRE_PROCESS to pre process a template containing the variables we need 2. Creating a Template::Plugins provider for LOAD_PLUGINS and a Template::Filters provider for LOAD_FILTERS and then loading them via whatever necessary methods. I don't think Jonathan is on the right track with "POC LOAD_FILTERS for raw". Check out bug 41279 for an example of what I mean of creating a new provider to hand to the Template object. 3. For "Koha" and "Asset", [% USE Koha %] and [% USE Asset %] aren't just loading the plugins they're also returning objects with those variable names. In theory, we could just pass them into the Template object using the VARIABLES config option. (That said, it looks like VARIABLES is ignored if STASH is provided, so good to keep in mind.) I think the same could work for "$raw". For filters, we could also alternatively take our $template object, call $template->context(), and then call "define_filter" on that. -- So lots of different ways that could all work. Happy to speak more to the provider stuff as well, since I spent a bit of time at Kohacon2025 and after working on Template provider classes. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38723 --- Comment #10 from David Cook <dcook@prosentient.com.au> --- Template::Toolkit is pretty cool in how customisable it is. I've had a pretty good time looking through its internals. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org