Today's rant outsourced: “
rant on = qw(HTML::Mason Embperl Template etc);”.
The principle many people suggest behind templating is that it allows “web people” to handle the HTML in whatever tool they use, while “code people” work on the code part of the application.
In reality what you get is templates that do not and can not validate as HTML, thus breaking the tools used by the “web people” and code that cannot be adequately tested by unit testing, thus breaking the tools used by the “code people”.
I have to deal with templates that contains mixed code - one “web person” got the page to “look” right, then the programmer abused that template by inserting multiple conditional statements to use the page as a search form in this instance, a results list in that instance, display the details of the requested result in another instance, perform some operation on that result in a different case. All that code mixed together in one template, rather than having the code living outside the template, with the template only used to prepare stuff for viewing by the user.
Code that lives in a template file isn't easily testable. The testing must involve the template engine, and relies on passing in certain parameters then checking the HTML received on the output side of the template engine. To test that a particular set of values is going to be generated by the code in the template, the tester must run the template through the template engine and then check that the HTML contains the expected values. This means bulkier test suites since we have to check the HTML output, not just the values calculated by a function. It also means that the tests designed to exercise the code will fail any time the “web people” alter the design of the site.