> > It seems problematic to me to require the programmers to do work when a > > designer wants to change the number of decimals in a page, for example. > > HTML::Template::Expr may present a solution to this particular desire, > although it isn't one I've come across. How often are HTML designers > fiddling with numeric formats? Are they really HTML designers if they can > deal with, say, a printf-style format string?
Yes, they are, and printf isn't so much harder than JavaScript, style sheets, and templating tags. One place where this comes up is date formatting and internationalization. Making the model objects understand locale and act appropriately is not always a good approach, and supplying a date format in the template - which is all about appearance anyway - seems appropriate. This can also be useful when the same date needs to be displayed in multiple ways, like an abbreviated format on one page and a fixed length format in an e-mail template. You could make the controller do this sort of formatting before passing data off to the view, but I think it's an awkward fit and increases the coupling between components unnecessarilly. Obviously there are lots of ways to solve these problems, but what I like about doing it in the template is that it puts these concerns in the hands of the people who control the rest of the look-and-feel issues in the application, and gets them out of the perl programmers' way. - Perrin