Module: Haml::Filters::Ruby

Includes:
Base
Defined in:
/build/buildd/ruby-haml-3.1.4/lib/haml/filters.rb

Overview

Parses the filtered text with the normal Ruby interpreter. All output sent to $stdout, such as with puts, is output into the Haml document. Not available if the :suppress_eval option is set to true. The Ruby code is evaluated in the same context as the Haml template.

Instance Method Summary (collapse)

Methods included from Base

included, #internal_compile, #lazy_require, #render, #render_with_options

Instance Method Details

- compile(compiler, text)

See Also:



278
279
280
281
282
283
# File '/build/buildd/ruby-haml-3.1.4/lib/haml/filters.rb', line 278

def compile(compiler, text)
  return if compiler.options[:suppress_eval]
  compiler.instance_eval do
    push_silent "_haml_old_stdout = $stdout\n$stdout = StringIO.new(_hamlout.buffer, 'a')\n".gsub("\n", ';') + text + "_haml_old_stdout, $stdout = $stdout, _haml_old_stdout\n_haml_old_stdout.close\n".gsub("\n", ';')
  end
end