in reply to Re^2: Control break with Template::Toolkit
in thread Control break with Template::Toolkit

Thank you all Monks for your responses! I think your discussion reflect that there is a compromise to be taken between placing too much logic (which seems a business tier concern) into the template, and on the other hand, building an extra elaborate API which caters only to some special use case. I was hoping that there would be some TT plugin to do this particular job, as it would keep the complexity hidden, my API simple, and perhaps be useful to many a user. Do you think it is an idea to push forward?

Thank you again!

  • Comment on Re^3: Control break with Template::Toolkit

Replies are listed 'Best First'.
Re^4: Control break with Template::Toolkit
by haj (Vicar) on Nov 15, 2019 at 16:57 UTC

    I would not expect such a plugin to exist, or worth writing. We have just covered one very special use case: categorizing sorted four-element arrays according to their third element, and formatting them as plain text. You may have noted that choroba's output is different from mine, but we don't know whether it matters.

    I myself would wrap the formatting into my template processing, either as a MACRO, where the transformation is done in TT language, or as a FILTER, where the transformation is done in a Perl module. Macros and filters can be predefined to the TT object, so the data template would just read [% categorize(data) %] with a macro, or [% data | categorize %] if you implement the formatting as a filter.