Passing a block through the haml template helper

20 views
Skip to first unread message

Mike Stenhouse

unread,
Apr 5, 2010, 9:36:10 AM4/5/10
to sinatrarb
Heya all

I've found myself needing to mix a haml layout with an erb template -
admittedly pretty niche! - and looking through tilt.rb I thought it'd
be possible to render my layout.haml with the erb rendering passed
through in a block.

haml(:layout, {:layout => false}){ erb(:template, :layout => false) }

At the moment the block gets lost in base.rb's haml helper. Is there
any particular reason that blocks aren't passed through? A quick
tinker and this works as I'd expected:

module Sinatra
module Templates
def haml(template, options={}, locals={}, &block)
render :haml, template, options, locals, &block
end
end
end

Cheers

Mike

Reply all
Reply to author
Forward
0 new messages