diff --git a/lib/haml.rb b/lib/haml.rb index ec43e202..64b9b208 100644 --- a/lib/haml.rb +++ b/lib/haml.rb @@ -564,8 +564,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir) # # [erb] Parses the filtered text with ERB, like an RHTML template. # Not available if the suppress_eval option is set to true. -# At the moment, this doesn't support access to variables -# defined by Ruby on Rails or Haml code. +# Embedded Ruby code is evaluated in the same context as the Haml template. # # [sass] Parses the filtered text with Sass to produce CSS output. # diff --git a/lib/haml/filters.rb b/lib/haml/filters.rb index 8205186a..dd149dbd 100644 --- a/lib/haml/filters.rb +++ b/lib/haml/filters.rb @@ -191,8 +191,9 @@ module Haml include Base lazy_require 'erb' - def render(text) - ::ERB.new(text).result(binding) + def compile(precompiler, text) + src = ::ERB.new(text).src.sub(/^_erbout = '';/, "").gsub("\n", ';') + precompiler.send(:push_silent, src) end end diff --git a/test/haml/results/filters.xhtml b/test/haml/results/filters.xhtml index 43c0b713..f022b68e 100644 --- a/test/haml/results/filters.xhtml +++ b/test/haml/results/filters.xhtml @@ -36,26 +36,32 @@ This pre is pretty deeply nested. Does interpolation work This one is, too. Nested, that is.

+ +
178