Bug 17971: TT syntax for notices - Add support for plurals
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Sat, 21 Jan 2017 13:26:27 +0000 (14:26 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 31 Mar 2017 11:11:41 +0000 (11:11 +0000)
commit3ee3cf10e61aaad8a47881fdc6cc565e74c847af
tree06e3488691282ea08d35816985225e0b95240589
parentd3cb1b0ab33b7070924611fd33e3a1aa3c34aab9
Bug 17971: TT syntax for notices - Add support for plurals

On of the awesome things we will be able to do with the TT syntax is the support of plurals.

For instance we will be able to send a list of items, checkouts, etc. to the notice template.
That way we will get rid of our custom syntax like <<items.content>> or <item></item> for instance.

The existing code already has the playground for that but it is not used.

Basically the idea is to add a "loops" key which can contain a list of
object to retrieve from the DB and send to the template.
For instance:
    loops => { overdues => [ $itemnumber_1, .., $itemnumber_N ] }

will send a variable "overdues" to the template. It will contain the
Koha::Checkout objects relative to the id passed.

There is one quite big inconvenient to this approach so far: since we
are still supporting the historical syntax, the objects can be fetch by
a script, then the script will send the id to GetPreparedLetter which
will refetch them.
This must be improved, but I suggest to do that later.

Test plan:
  prove t/db_dependent/Letters/TemplateToolkit.t
should return green

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Letters.pm
t/db_dependent/Letters/TemplateToolkit.t