jaa has asked for the wisdom of the Perl Monks concerning the following question:
Blush for asking a newbie Template::Toolkit question! I am more looking for general pointers in the right direction, (I know there is always a pain barrier when getting my head around a new tool...)
As an e.g. in my playing around I want to:
But the only way I have found to do this is:[% uc(myvar) %]
[% use String %] [% String.new(myvar).upper() %]
This is a trivial example - I can imagine that I will end up implement my own class with ALL my common view mutator - upper() lower() proper() escape() commify() etc
Yes, I know about HTML.escape() and I am sure that there are date classes with formatting mutators...
Is this what everyone else does? Is there a 'better way'?
Actually I am hoping for a 'Doh!' when you point out that these are all built-ins in TT and that I have not found the right docs!
I am reluctant to do this formatting in the Model components as I see it as part of rendering an HTML view (eg escape(). I also think it kind-of breaks the 'keep it easy for template tweakers' principle.
Many thanks for your pearls!
Jeff
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Toolkit::Template - uc() and lc(), other simple formatting mutexes
by tachyon-II (Chaplain) on Apr 23, 2008 at 11:16 UTC | |
by jaa (Friar) on Apr 23, 2008 at 12:43 UTC | |
|
Re: Toolkit::Template - uc() and lc(), other simple formatting mutexes
by haoess (Curate) on Apr 23, 2008 at 11:13 UTC | |
|
Re: Template::Toolkit - uc() and lc(), other simple formatting mutators - see TT Filters!
by perrin (Chancellor) on Apr 23, 2008 at 13:52 UTC | |
|
mutex?
by ForgotPasswordAgain (Vicar) on Apr 23, 2008 at 11:00 UTC | |
by jaa (Friar) on Apr 23, 2008 at 11:06 UTC |