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"
You can just use Sinatra's haml function:
EDIT: !!! OUTDATED !!! Read Jason's answer below!
What are you trying works in
rails
!Sinatra
has nopartial
method. An implementation ofpartial
onSinatra
looks like this (source gist) from github:Including this method, you may call
partial
in your.haml
files, like= partial("partial_name")
If you want to
render
a view in an other view syntax is= render(:haml,:'rel_path_to_view',:locals => {:optional => option})
Notice the syntax differences between
rails
andsinatra
regardingrender
method!Here's how I do it (more simply than @kfl62's answer, more feature-rich than @jm3's answer):
Use it in your Haml file like:
Or you could just do this:
And include your partial with: