[Nitro] accessing children within an element

Jimmy Jazz Jimmy.Jazz at gmx.net
Fri Jul 6 17:15:09 EDT 2007


Hello,

I took some time to discover why it was not possible to access a child
content from within an element :)

The instance variable @_children should have been declared as a class
variable @@_children. Otherwise you will lose what you have filled in
after calling the method add_child in
raw/lib/raw/compiler/filter/elements/element.rb.

Also, i'm a bit confused about how to use it.

If you write something like,

<Page>
<Box id="mybox">
  Jack
</Box>
</Page>

and you declare a class Box

Class Page
Class Box < Raw::Element
  %{
    <div id="mylayout">
     Oh Jack ...
    </div>
  }
end
end

the layout mylayout of the class Box  will be completely ignored if you
call the child "mybox" directly

def render
  #{content :mybox}
end

otherwise the layout will be used when you access the whole page like that:

def render
  #{content}
end

That could be really confusing for anyone and it can be also hard to
decide where to declare css layouts for an element in the class, the
render or the htmlx file. :(

Jj
-- 

            |\      _,,,---,,_
      ZZZzz /,`.-'`'    -.  ;-;;,_
           |,4-  ) )-,_. ,\ (  `'-'
          '---''(_/--'  `-'\_)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20070706/af7c8fb4/attachment.html 


More information about the Nitro-general mailing list