module Haml::Filters::Ruby

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 {file:HAML_REFERENCE.md#suppress_eval-option `:suppress_eval`} option is set to true. The Ruby code is evaluated in the same context as the Haml template.

Public Instance Methods

compile(compiler, text) click to toggle source

@see Haml::Filters::Base#compile

# File lib/haml/filters.rb, line 275
      def compile(compiler, text)
        return if compiler.options[:suppress_eval]
        compiler.instance_eval do
          push_silent "            _haml_old_stdout = $stdout
            $stdout = StringIO.new(_hamlout.buffer, 'a')
".gsub("\n", ';') + text + "            _haml_old_stdout, $stdout = $stdout, _haml_old_stdout
            _haml_old_stdout.close
".gsub("\n", ';')
        end
      end