Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > aop presentational items in Rails?

Reply
Thread Tools

aop presentational items in Rails?

 
 
leon breedt
Guest
Posts: n/a
 
      07-26-2004
hi,

i was just wondering, does Rails offer, or plan to offer,
HTML::Mason-like AOP for templates?

the Masonic notion does not map directly to the Rails way of doing
things, i suspect,
i think the closest thing Rails has to a component in Mason
terminology is the template, and i'll use template below when i mean
"component" in HTML::Mason terms.

with HTML::Mason, you can define a "autohandler" for any particular
path. what this means is that the autohandler is a parent (for the
purposes of presentational output) for any template contained at or
below that path.

it has complete control of the output and can decide where the output
of any contained templates should go. you can obviously override it
selectively for components that you don't want this behaviour to apply
to.

the concept is very powerful though, as the wrapped component need
know nothing about how its being wrapped. this is also vastly superior
to include mechanisms, as it is completely DRYish

Mason examples:

/autohandler - gets invoked for all paths
/admin/autohandler - gets invoked for everything below /admin

there is of course also the Mason concept of "dhandler", or "default
handler", when nonexistent paths are attempted to be accessed, but
thats a whole different discussion.

the autohandler feature is something i would not be able to live
without though, as it has meant a vast reduction in LOC for my web
apps.

comments?

leon


 
Reply With Quote
 
 
 
 
Florian Weber
Guest
Posts: n/a
 
      07-26-2004

hi!

not sure if i understand you correct, but maybe you
search for something like html decoration stuff? check out
the 'layout' method for the actionpack controllers...

http://ap.rubyonrails.org/classes/Ac...roller/Layout/
ClassMethods.html


ciao!
florian


On Jul 26, 2004, at 10:20 Uhr, leon breedt wrote:

> hi,
>
> i was just wondering, does Rails offer, or plan to offer,
> HTML::Mason-like AOP for templates?
>
> the Masonic notion does not map directly to the Rails way of doing
> things, i suspect,
> i think the closest thing Rails has to a component in Mason
> terminology is the template, and i'll use template below when i mean
> "component" in HTML::Mason terms.
>
> with HTML::Mason, you can define a "autohandler" for any particular
> path. what this means is that the autohandler is a parent (for the
> purposes of presentational output) for any template contained at or
> below that path.
>
> it has complete control of the output and can decide where the output
> of any contained templates should go. you can obviously override it
> selectively for components that you don't want this behaviour to apply
> to.
>
> the concept is very powerful though, as the wrapped component need
> know nothing about how its being wrapped. this is also vastly superior
> to include mechanisms, as it is completely DRYish
>
> Mason examples:
>
> /autohandler - gets invoked for all paths
> /admin/autohandler - gets invoked for everything below /admin
>
> there is of course also the Mason concept of "dhandler", or "default
> handler", when nonexistent paths are attempted to be accessed, but
> thats a whole different discussion.
>
> the autohandler feature is something i would not be able to live
> without though, as it has meant a vast reduction in LOC for my web
> apps.
>
> comments?
>
> leon
>
>
>




 
Reply With Quote
 
 
 
 
leon breedt
Guest
Posts: n/a
 
      07-26-2004
On Mon, 26 Jul 2004 17:26:26 +0900, Florian Weber
<(E-Mail Removed)> wrote:
> http://ap.rubyonrails.org/classes/Ac...roller/Layout/
> ClassMethods.html


seems like i'll have to a bit more reading, but from the documentation
available there, it looks like layouts are intended to address exactly
the concerns i had regarding duplication.

thanks!
leon


 
Reply With Quote
 
Nicholas Van Weerdenburg
Guest
Posts: n/a
 
      07-27-2004
For those that know, would this be akin to Tiles in Struts (in a
somewhat different form)?

Thanks,
Nick

leon breedt wrote:

>On Mon, 26 Jul 2004 17:26:26 +0900, Florian Weber
><(E-Mail Removed)> wrote:
>
>
>>http://ap.rubyonrails.org/classes/Ac...roller/Layout/
>>ClassMethods.html
>>
>>

>
>seems like i'll have to a bit more reading, but from the documentation
>available there, it looks like layouts are intended to address exactly
>the concerns i had regarding duplication.
>
>thanks!
>leon
>
>
>



 
Reply With Quote
 
David Heinemeier Hansson
Guest
Posts: n/a
 
      07-27-2004
> For those that know, would this be akin to Tiles in Struts (in a
> somewhat different form)?


I looked at both SiteMesh and Tiles before doing layouts in Action
Pack. So yes, there was indeed inspiration, but mostly in the sense of
what _not_ to do. I think both approaches are over-engineered to the
point of being laborious and hard to understand. But I feel that about
many things, so...

Anyway, in my opinion, the benefit of SiteMesh and Tiles is the
inversion principle. Instead of having content templates reference
common layout (through include header/footer and the like), you make
the layout reference the content. That's where at least 80% of the
benefit is hidden to me. And layouts in Action Pack implements that for
5% of the effort (it's really just a string!).
--
David Heinemeier Hansson,
http://www.rubyonrails.org/ -- Web-application framework for Ruby
http://www.instiki.org/ -- A No-Step-Three Wiki in Ruby
http://www.basecamphq.com/ -- Web-based Project Management
http://www.loudthinking.com/ -- Broadcasting Brain
http://www.nextangle.com/ -- Development & Consulting Services



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
On presentational Javascript gu HTML 33 11-25-2008 09:07 PM
Will OOPs be dead now... is it the next hype AOP marathikaka@yahoo.co.in MCSD 1 08-21-2005 03:42 PM
Using AOP to implement dynamic proxies Michael N. Christoff Java 3 12-08-2003 05:12 PM
XDoclet, JBOSS-AOP Example3 X_AWemner_X Java 0 08-07-2003 04:18 PM
good book on Apsect Oriented programming (AOP) Anu Raj Pradhan Java 0 07-14-2003 10:10 PM



Advertisments