Create a helper or something for haml with ruby on rails Create a helper or something for haml with ruby on rails ruby ruby

Create a helper or something for haml with ruby on rails


You can use haml_tag too

def content_box  haml_tag :div, :class => "holder" do    haml_tag :div, :class => "top"    haml_tag :div, :class => "content" do      yield    haml_tag :div, :class => "bottom"  endend

and in haml

%html  %head  %body    Maybee some content here.    = content_box do      Content that goes in the content_box like news or stuff


The typical solution to this is to use a partial.

Or a helper method in your _helper.rb file:

def content_box(&block)  open :div, :class => "holder" do # haml helper    open :div, :class => "top"    open :div, :class => "content" do      block.call    end    open :div, :class => "bottom"  endend

And in haml:

%html  %head  %body    Maybee some content here.    = content_box do      Content that goes in the content_box like news or stuff