Koha has evolved to use Template Toolkit for many uses outside of generating slips and notices for patrons. Historically, each of these areas processed template toolkit in a slightly different way. We should add a module to allow Template Toolkit syntax to be processed in a standard and generic way such that all non-notice TT syntax is handled and processed the consistently.
Created attachment 147085 [details] [review] Bug 33030: Add standardized subroutine for processing Template Toolkit syntax outside of notices Koha has evolved to use Template Toolkit for many uses outside of generating slips and notices for patrons. Historically, each of these areas processed template toolkit in a slightly different way. We should add a module to allow Template Toolkit syntax to be processed in a standard and generic way such that all non-notice TT syntax is handled and processed the consistently. Test Plan: 1) Apply this patch 2) prove t/db_dependent/Letters/TemplateToolkit.t
Created attachment 147182 [details] [review] Bug 33030: Add standardized subroutine for processing Template Toolkit syntax outside of notices Koha has evolved to use Template Toolkit for many uses outside of generating slips and notices for patrons. Historically, each of these areas processed template toolkit in a slightly different way. We should add a module to allow Template Toolkit syntax to be processed in a standard and generic way such that all non-notice TT syntax is handled and processed the consistently. Test Plan: 1) Apply this patch 2) prove t/db_dependent/Koha/Items.t
Created attachment 148076 [details] [review] Bug 33030: Add unit tests
The tests currently fail: prove t/db_dependent/Koha/Items.t t/db_dependent/Koha/Items.t .. 6/16 # Looks like you planned 9 tests but ran 4. t/db_dependent/Koha/Items.t .. 15/16 # Failed test 'search_ordered' # at t/db_dependent/Koha/Items.t line 1904. DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'published_on_template' in 'field list' at /kohadevbox/koha/t/lib/TestBuilder.pm line 384 # Looks like your test exited with 11 just after 15. t/db_dependent/Koha/Items.t .. Dubious, test returned 11 (wstat 2816, 0xb00) Failed 2/16 subtests Test Summary Report ------------------- t/db_dependent/Koha/Items.t (Wstat: 2816 Tests: 15 Failed: 1) Failed test: 15 Non-zero exit status: 11 Parse errors: Bad plan. You planned 16 tests but ran 15. Files=1, Tests=15, 5 wallclock secs ( 0.04 usr 0.00 sys + 3.69 cusr 0.58 csys = 4.31 CPU) Result: FAIL
(In reply to David Nind from comment #4) > The tests currently fail: > > prove t/db_dependent/Koha/Items.t They are passing for me! Did you apply the dependency (Bug 33039) beforehand and run updatedatabase.pl? I get your error if I have applied both bugs but don't run updatedatabase.pl before running the unit tests.
Created attachment 150511 [details] [review] Bug 33030: Add standardized subroutine for processing Template Toolkit syntax outside of notices Koha has evolved to use Template Toolkit for many uses outside of generating slips and notices for patrons. Historically, each of these areas processed template toolkit in a slightly different way. We should add a module to allow Template Toolkit syntax to be processed in a standard and generic way such that all non-notice TT syntax is handled and processed the consistently. Test Plan: 1) Apply this patch 2) prove t/db_dependent/Koha/Items.t Signed-off-by: David Nind <david@davidnind.com>
Created attachment 150512 [details] [review] Bug 33030: Add unit tests Signed-off-by: David Nind <david@davidnind.com>
(In reply to Kyle M Hall from comment #5) > (In reply to David Nind from comment #4) > > The tests currently fail: > > > > prove t/db_dependent/Koha/Items.t > > They are passing for me! Did you apply the dependency (Bug 33039) beforehand > and run updatedatabase.pl? I get your error if I have applied both bugs but > don't run updatedatabase.pl before running the unit tests. It works with the updatedatabase - now signed off!
> It works with the updatedatabase - now signed off! Thanks David!
$processed = process_tt($template, $vars); Process the given Template Toolkit string, passing the given hashref of vars to the template, returning the processed string. It is written correctly. But when I see $template, I still think of a file..
Created attachment 153142 [details] [review] Bug 33030: Add standardized subroutine for processing Template Toolkit syntax outside of notices Koha has evolved to use Template Toolkit for many uses outside of generating slips and notices for patrons. Historically, each of these areas processed template toolkit in a slightly different way. We should add a module to allow Template Toolkit syntax to be processed in a standard and generic way such that all non-notice TT syntax is handled and processed the consistently. Test Plan: 1) Apply this patch 2) prove t/db_dependent/Koha/Items.t Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 153143 [details] [review] Bug 33030: Add unit tests Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Pushed to master for 23.11. Nice work everyone, thanks!
Can we stop with "Util" in package names please?
(In reply to Jonathan Druart from comment #14) > Can we stop with "Util" in package names please? I thought we did have a code guideline outlawing it but apparently we don't. Worth adding one for it I think.
Holding off on backport here thinking we may want to change the module name ;P