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.
Created attachment 59426 [details] [review] 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
Created attachment 59427 [details] [review] Bug 17971: Add support for objects represented by fk For instance an issue is not fetch from its fk but using the fk itemnumber. We need to support them.
Created attachment 59529 [details] [review] [SIGNED-OFF] 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>
Created attachment 59530 [details] [review] [SIGNED-OFF] Bug 17971: Add support for objects represented by fk For instance an issue is not fetch from its fk but using the fk itemnumber. We need to support them. Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Applying on top of 17970: Applying: Bug 17971: TT syntax for notices - Add support for plurals fatal: sha1 information is lacking or useless (C4/Letters.pm). Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge.
Created attachment 60987 [details] [review] 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>
Created attachment 60988 [details] [review] Bug 17971: Add support for objects represented by fk For instance an issue is not fetch from its fk but using the fk itemnumber. We need to support them. Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 61710 [details] [review] 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>
Created attachment 61711 [details] [review] Bug 17971: Add support for objects represented by fk For instance an issue is not fetch from its fk but using the fk itemnumber. We need to support them. Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Created attachment 61712 [details] [review] Bug 17971 (QA Followup) Clarify comment
Pushed to master for 17.05, thanks Jonathan, Nick!
This won't get ported back to 16.11.x as it is an enhancement.