Skip to content
  • joubu's avatar
    Bug 17971: TT syntax for notices - Add support for plurals · 3ee3cf10
    joubu authored and Kyle M Hall's avatar Kyle M Hall committed
    
    
    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: default avatarJosef Moravec <josef.moravec@gmail.com>
    
    Signed-off-by: default avatarNick Clemens <nick@bywatersolutions.com>
    
    Signed-off-by: default avatarKyle M Hall <kyle@bywatersolutions.com>
    3ee3cf10