>
>
> > How can I guess the view's name in my layout method?
>
> If you're using Markaby (that is, templates written in Ruby under
> MyApp::Views) and Ruby 1.9 you can use __method__:
>
> module App::Views
> def foo
> p "I'm inside: #{__method__}"
> end
> end
>
> But you can't use that in a layout or partial though (it would just
> return "layout" or the name of the partial)…
>
My question was about the layout. Suppose that Alfa and Beta are
menu items in the layout, and I want to mark the current menu item
with different appearance:
module App::Views
def layout
case ..... #<--- Which view am I currently rendering? :alfa or :beta?
when :alfa
# generate an alfa-selected menu
when :beta
# generate a beta-item-selected menu
end
div(:class => :content) {
self << yield
}
end
def alfa
"Alfa"
end
def beta
"Beta"
end
end
_______________________________________________
Camping-list mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/camping-list