0

I am trying to build a Sinatra app with HAML and use a layout to be able to break my site down into partials:

layout.haml

!!!
%html
    %head
        = partial :head
    %body
        = partial :header
        = partial :#{@template}
        = partial :footer

Where my Sinatra app is calling layout.haml like so:

get '/test' do      
    @template = "\"test/index\""

    haml :"layout"
end

To try to pull in:

views/
|----test/
    |----_index.haml

Which gives me the error:

wrong number of arguments (0 for 1..2)

I have also tried redefining a number of different combinations with no success:

@template = ":\"test/index\""
= partial #{@template}

@template = "test/index"
= partial :#{@template}

Note: I am using Sinatra Partials

Am I going about this entirely the wrong way? My brain is really suffering trying to figure out how to employ HAML for such a basic concept of DRY templating.

waffl
  • 5,179
  • 10
  • 73
  • 123

1 Answers1

2

Ah it was so simple afterall.. With the help of this question, I realized now of course that everything is wrapped with layout.haml and I simply needed to place the appopriate yield statement.

layout.haml

!!!
%html
    %head
        = partial :head
    %body
        = partial :header
        = yield
        = partial :footer

And call the template as usual:

get '/test' do    
    haml :"test/index"
end
Community
  • 1
  • 1
waffl
  • 5,179
  • 10
  • 73
  • 123