Use the :local_assigns option. So, for example,
# script.rb
foo = 'bar'
engine = Haml::Engine.new(File.read('index.haml'), :local_assigns => {:foo =>
foo})
puts engine.render
For future reference, this and other useful options are in the "Options"
section of the docs.
- Nathan
Marze wrote:
> I'm trying to use haml outside Rails, I'm kind of newbie and I don't
> know if I missed something
>
> # script.rb
> foo = 'bar'
> engine = Haml::Engine.new(File.read('index.haml'))
> puts engine.render
>
> # index.haml
> %p= foo
>
>
> The output doesn't render the variable, how do i pass the locals to
> the template?
> sorry if this is already documented, I searched in the docs with no
> luck
>
> Thanx, this is the greatest render engine for Ruby! (well, Markaby
> also rocks)
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---