https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39716 --- Comment #12 from Lisette Scheer <lisette@bywatersolutions.com> --- Created attachment 211796 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211796&action=edit Bug 39716: (follow-up) Report template toolkit directives that aren't uppercase Notices are processed without ANYCASE, so template toolkit only knows its directives in uppercase. A lowercase directive is now reported: - as an error when the field doesn't compile (e.g. [% if x %]...[% END %]) - as a warning when it compiles but silently does something else (e.g. [% else %], [% next %], or "in" in [% FOREACH x in y %], which are read as variables) The lowercase operators and, or, not, mod and div work and aren't reported, nor are variables the template defines with these names, nor variables the notice receives with these names when they are used as variables: in OAI_HARVEST_REPORT, [% set %] is the OAI set of the harvest, while [% set x = 1 %] is still reported. This also processes templates with the includes of their language, as when they are sent, and adds a Cypress test for the checks when saving (errors prevent saving, warnings ask to confirm). While the templates are checked before saving, the Save button shows "Saving..." and is disabled, as when saving system preferences (KOHA.AJAX.MarkRunning), so that the notice is not saved twice; it is restored when the notice is not saved because of problems. The line numbers next to the message body are removed when a template is emptied, follow the lines as they are edited without slowing typing in long templates, and no longer leave observers behind. "or" between alternatives is translated without its spaces. Test plan: 1. Apply the patch, run yarn build and restart_all 2. Edit a notice and add [% if borrower.firstname %]x[% END %] 3. Save: an error explains that "if" must be written "IF" 4. Replace it with [% IF borrower.firstname %]x[% else %]y[% END %] 5. Save: a warning explains that "else" is read as a variable 6. Edit OAI_HARVEST_REPORT (Catalog), which uses [% set %], and save: => No problem is reported Add [% set x = 1 %] on a new line and save: => An error is reported, for that line only 7. prove t/db_dependent/Koha/Notice/Template.t 8. yarn cypress run --spec t/cypress/integration/Tools/NoticeValidation_spec.ts 9. Edit a notice and click Save: => While the notice is checked, the button shows "Saving..." and cannot be clicked again (In the browser's developer tools, set the network to a slow speed, e.g. "Slow 3G" in the throttling menu of the Network tab, so that this lasts long enough to see; set it back to "No throttling" afterwards) 10. Make a template with an error (e.g. [% IF x %]), click Check, then empty the template's subject and message body and click Check again: => The problems and the line numbers are gone Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.