Re: Mason 2.0 thoughts
Jonathan Swartz <[email protected]> Sat, 12 May 2007 21:30:47 -0700
| Newsgroups | gmane.comp.web.mason.devel |
|---|---|
| Message-ID | <[email protected]> |
>>
>> I would hate to give up cache_self; it's one of the things I have
>> grown to
>> really appreciate about mason vs. TT.
>
> If you're using Catalyst, it's really easy to implement a cache_self
> equivalent in your controller code using Catalyst's caching plugins. I
> don't think it really requires any knowledge of the view.
>
> All you have to do is capture the output the first time through,
> which is
> pretty easy to under Catalyst, since there's a chance to step in
> betwee
> rendering and actually sending output to the client.
That works for caching a whole page, which in my experience is rarely
possible on a dynamic site. cache_self allows you to cache the output
of an arbitrary component, such as a form menu or nav bar.
That said, I would prefer to provide a replacement for cache_self
that looks more like Rails' fragment caching (http://
api.rubyonrails.org/classes/ActionController/Caching/Fragments.html).
e.g.
<% Cache (... cache flags ...) { %>
...
[a component or part of a component]
...
<% } %>
Of course this syntax doesn't work out of the box in Mason because
Perl doesn't support Ruby-style blocks, and our <% %> doesn't have
the right semantics. But you get the idea. I want it to be just as
easy to cache a portion of a component as cache_self makes it to
cache an entire component.
Jon
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/