Ash Berlin wrote:
> What exactly do mason autohandlers do?
>
In fact, the great power of Mason isn't autohandlers, but its component
inheritance system. Autohandlers just make it very easy to use.
They're a nice way to automate certain tasks, such as including
headers/footers to your pages (and by way how all autohandlers are
called, it's easy to add custom code to various pages).
For example, if you have a site layout like this:
/autohandler
/index.html
/admin/autohandler
/admin/index.html
In the toplevel autohandler you add headers and footers and it'll look
like this (sorry the syntax is probably different, I worked with Mason
long ago):
<html>
... header content
% $m->next_comp
... footer content
</html>
When someone requests /index.html, the autohandler will be called first;
inside it, we call $m->next_comp which fetches the next component
(index.html). This way you add headers and footers to any page without
having to explicitly include files in every page.
Now, in /admin/autohandler you can have the following:
% if ($has_admin_privileges) {
% $m->next_comp; # display admin page
% } else {
... display login form ...
% }
When /admin/SOMETHING.html is requested, the toplevel autohandler still
gets called. In it, $m->next_comp refers to the second autohandler. So
pages will still automatically have headers and footers. In the second
autohandler, $m->next_comp refers to SOMETHING.html, but it serves it
only if the user has enough privileges; otherwise it'll show the login form.
It's an elegant way to write websites.
Read about them here: http://masonhq.com/docs/manual/Devel.html#autohandlers
I wish TT had something like this. OTOH, this might be simply out of
the scope of TT (such functionality should be implemented in the
mod_perl handler and not in the template system). The really one thing
I miss from TT is addressing relative files, which is something TT3 will
be able to do:
http://www.mail-archive.com/[email protected]/msg09162.html
-Mihai
--
www.dynarchlib.com - the mighty AJAX toolkit
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates