Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render a partial in sinatra view (haml in haml)?

I have a simple sinatra app that uses haml and sass for the views. One of the views (located in the views folder) is a partial for my navigation menu. I am trying to render it from index.haml but I get the following error: wrong number of arguments (1 for 2)

I am trying to render it with the following lines in index.haml

.navigation
  = render :partial => "nav"
like image 835
Ben Avatar asked Oct 20 '10 04:10

Ben


2 Answers

You can just use Sinatra's haml function:

= haml :nav
like image 141
Jason Avatar answered Sep 27 '22 21:09

Jason


Or you could just do this:

helpers do
  def partial(page, options={})
    haml page.to_sym, options.merge!(:layout => false)
  end
end

And include your partial with:

= partial( "something-rad" )
like image 43
jm3 Avatar answered Sep 27 '22 20:09

jm3