Last Updated: February 25, 2016
·
1.416K
· BRIMIL01

HAML Engine Render Scope

When rendering a template using the HAML engine and there are instance variables that should be used remember to set the scope on render. The easiest is just to set it to self.

@something = "text"
template = File.read("path/to/template")
result = Haml::Engine.new(template).render(self)