[Chicago-talk] TT vs Mason

Jonathan Rockway jon at jrock.us
Thu Jun 15 14:21:53 PDT 2006

It depends on what sort of development style you're using.  If you're 
doing MVC, I would recommend Mason.  I use TT for my MVC applications 
that I've done thusfar, and don't like the way it integrates.  For 
example, if you have some text that contains UTF-8 characters, and want 
to output those UTF-8 characters as a URL in valid strict XHTML, you 
have to escape them (%13%37, etc).  Where to do this in MVC?  In the 
view, of course.  Unfortunately, when you start doing processing in TT, 
things get ugly.  There's a uriescape in the CGI TT extension that I 
use, but it starts getting less and less clean from there.  If I wanted 
to do something more complex, I'd have to write my own TTx, and that's 
kind of a waste of effort, IMO.  (There's nothing reusable, so it's not 
worth writing a module for... but there's no other way to extend TT.)

If you use Mason, you'll be able to make a simple subroutine call 
without having to write a TT extension.  It's just a line of code inside 
some HTML.  Convenient, and the cleanest way to do things, IMO.

(Of course, you could do the escaping in the Controller or even the 
Model, but that's ugly and if you do things like that, you might as well 
not use MVC.)

However, if you're doing it the good-old-CGI way, then TT is much 
better.  There's nothing wrong with massaging your output in a CGI 
script, so you can setup all your variables to be HTML-ized as you like 
them, and then let TT make the actual page.  Very nice, and the 
templates are very clean and maintainable.  (But then, the actual 
controller isn't as maintainable.  Tradeoffs, tradeoffs.)

All in all, I don't think either Mason or TT are optimal, and might be 
writing my own templating system in the future. ;)

Hope this helps.

Jonathan Rockway

Elias Lutfallah wrote:
> All,
> I understand that some people prefer the Template Toolkit over Mason.
 > >8 -snip- 8<

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 370 bytes
Desc: OpenPGP digital signature
Url : http://mail.pm.org/pipermail/chicago-talk/attachments/20060615/c9e9684a/attachment.bin 

More information about the Chicago-talk mailing list