This just isn't true. First and foremost, why does your Mason template
even think about considering direct usage of DBI? In a <table> tag? With
a raw SQL query? Can't one set $c->stash->{rowset} to whatever DBIC
returns, and then declare:
<%args>
$rowset
</%args>
Suddenly, the $rowset is available in your template without you having
to fetch it manually. Or you could just use $c directly since it's set
up as a global variable, at least when you're inheriting from
C::V::Mason anyway.
This is not to say that I've seen apps written entirely in Mason so that
Mason bears the duties of the model, view, and controller, all at the
same time. Catalyst, however, gives us the ability to relieve it of any
extra duties outside of pure display of data.
Jonathan Rockway wrote:
Max Afonov wrote:
Why don't I _ever_ hear about Mason on this list? How is TT better than
Mason anyway?
...not meaning to start a flame war...
Mostly because mason becomes an unreadable mess, just like PHP. Take a
look at the RT source code, or my clever example here:
Mason:
<table><% my $sth = $dbh->prepare('SELECT columns FROM table WHERE
something=1'); for($row = $sth->fetchrow_arrayref){ %></table>
That Other Language:
<table><?php $sth =
mysql_execute_a_query_or_something_omg_this_is_long("SELECT columns FROM
table WHERE something=1");
for(mysqllni_get_those_results_out_of_the_result_handle($sth) as $row){
print "<tr><td>". $row['0']. "</td><td>". $row['1']. "</td></tr>"; }
?></table>
TT (in Cat with DBIC):
<table>
[% WHILE (row = rows.next) %]
<tr>
<td>[% row.name | html %]</td><td>[% row.whatever | html %]</td>
</tr>
[% END %]
</table>
ClearSilver (with some preparation in the view):
<table>
<?cs each:row = rows ?>
<tr><td><?cs var:name ?></td>
<td><?cs var:whatever ?></td></tr>
<?cs /each ?>
</table>
Mason and PHP are both fine tools, but they are a little too flexible.
If you want web designers to be able to work on your templates, then you
can't have "print" statements in your template. If you want your code
to be maintainable, you can't prepare your database queries in the
template. Mason and PHP degenerate to things like the above example
because it's really easy to let happen. (Look at the RT source. Good
people working on it. Completely useless templates.)
TT definitely lets you write bad code too, but [% EVAL %] is off by
default (and hence I omitted it in my example). ClearSilver ensures
that you don't do anything code-wise in your templates, at the cost of
not being able to do anything code-wise in your templates :)
Pick the system you like, but be aware of the problems that PHP and
Mason encourage.
Regards,
************************
MLB.com: Where Baseball is Always On
_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/