Folks,

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:

[% uc(myvar) %]
But the only way I have found to do this is:
[% 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


In reply to Template::Toolkit - uc() and lc(), other simple formatting mutators - see TT Filters! by jaa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.