You can use tilt gem
For example, the template foo.html.haml :
!!! 5 %html %head %title Rotten Potatoes! %body %h1.title Rotten Potatoes! Hey = yield!
Then pass the name of the temple:
template = Tilt::ERBTemplate.new('foo.html.haml') output = template.render { 'Joe' } # => html code with phrase 'Hey Joe!'
source share