[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] Template Toolkit l33t hax0rs



Our TT stuff is getting pretty slick... We're doing multilanguage templates

[% lang_code = q.param("lang_code") || "en-us" %]
[% IF lang_code == "fr";
  lang_text8   = "fr:Rate total:"
  lang_text9   = "fr:Taxes:"
  lang_text10  = "fr:Fees:"
  lang_text11  = "fr:Total:"
;ELSE;
  lang_text8   = "Rate total:"
  lang_text9   = "Taxes:"
  lang_text10  = "Fees:"
  lang_text11  = "Total:"
;END %]

Obviously we don't speak french or those fr: strings would actually be in French. We've got a company translating for us at some point.

Then, later, we're using my objects directly in TT, TT pipes, format(), basic TT algebra and flow control...

        [% IF suppressed != "S" %]
          [% rates = detail.rates_total;
             taxes = detail.L_surcharges_data.total_taxes | format('%0.2f');
             fees  = detail.L_surcharges_data.total_fees  | format('%0.2f');
             total = rates + taxes + fees  %]
          $lang_text8  $rates $detail.currency<br>
          $lang_text9  $taxes $detail.currency<br>
          $lang_text10 $fees  $detail.currency<br>
          $lang_text11 $total $detail.currency<br>
        [% END %]

$TT_5k1lz++;

Grin,

j