hello, I was wondering if the above is possible. I mean like this way.
def foo @bar = 8 end
... <span if="@bar = 8">jeeh</span> ...
class Page < Nitro::Element def render %{ <html> <head> <title>#{@title}</title> </head> <body> <span if="@bar = 8"> #{content} </span> </body> </html> } end end
<Page title="hoihoi"> jeeh </Page>
but then @bar is nil in the element page, this is logic because it is not an instance variable of the element class, but how can I then pass arguments from the template to the element?
btw. I put a session variable in the instance variable so if you can use session one way or another in a element it is fine too?
(1 attempts)
dickdawg answered:
Each attribute set on the element in your xhtml document will be visible as an instance variable to the class implementing the element (Page, in this case). So for:
<Page bar="8" title="My Page">...</Page>
class Page < Nitro::Element def render out = %~ <html> <head> <title>#{@title}</title> </head> <body> ~ if @bar == 8 out += %~ <span> #{@_text} </span> ~ end out += %~ </body> </html> ~ out end end