On Thu, Oct 13, 2011 at 23:36, Nokan Emiro <uzleep...@gmail.com> wrote:
> 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

You could always override the render-method yourself:

module App::Helpers
  def render(name, *rest)
    @template_name = name.to_s unless name == :layout
    super
  end
end

module App::Views
  def layout
    h1 "I'm in #{@template_name}"
    self << yield
  end
end
_______________________________________________
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

Reply via email to