aop presentational items in Rails?

Discussion in 'Ruby' started by leon breedt, Jul 26, 2004.

  1. leon breedt

    leon breedt Guest

    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
     
    leon breedt, Jul 26, 2004
    #1
    1. Advertising

  2. 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/ActionController/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
    >
    >
    >
     
    Florian Weber, Jul 26, 2004
    #2
    1. Advertising

  3. leon breedt

    leon breedt Guest

    On Mon, 26 Jul 2004 17:26:26 +0900, Florian Weber
    <> wrote:
    > http://ap.rubyonrails.org/classes/ActionController/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
     
    leon breedt, Jul 26, 2004
    #3
  4. 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
    ><> wrote:
    >
    >
    >>http://ap.rubyonrails.org/classes/ActionController/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
    >
    >
    >
     
    Nicholas Van Weerdenburg, Jul 27, 2004
    #4
  5. > 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
     
    David Heinemeier Hansson, Jul 27, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anu Raj Pradhan
    Replies:
    0
    Views:
    390
    Anu Raj Pradhan
    Jul 14, 2003
  2. X_AWemner_X

    XDoclet, JBOSS-AOP Example3

    X_AWemner_X, Aug 7, 2003, in forum: Java
    Replies:
    0
    Views:
    700
    X_AWemner_X
    Aug 7, 2003
  3. Michael N. Christoff

    Using AOP to implement dynamic proxies

    Michael N. Christoff, Dec 5, 2003, in forum: Java
    Replies:
    3
    Views:
    698
    Deepak Nayal
    Dec 8, 2003
  4. Tomer Ben-David

    AOP Java its implications

    Tomer Ben-David, Jan 28, 2004, in forum: Java
    Replies:
    3
    Views:
    411
    Dale King
    Feb 5, 2004
  5. gu
    Replies:
    33
    Views:
    1,541
    David Mark
    Nov 25, 2008
Loading...

Share This Page