Module: Erubis::Helpers::RailsHelper::TemplateConverter

Included in:
ActionView::Base, ActionView::TemplateHandlers::ErubisHandler
Defined in:
lib/erubis/helpers/rails_helper.rb

Instance Method Summary collapse

Instance Method Details

#_convert_template(template) ⇒ Object

covert eRuby string into ruby code



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/erubis/helpers/rails_helper.rb', line 90

def _convert_template(template)    # :nodoc:
  #src = ::Erubis::Eruby.new(template).src
  klass      = ::Erubis::Helpers::RailsHelper.engine_class
  properties = ::Erubis::Helpers::RailsHelper.init_properties
  show_src   = ::Erubis::Helpers::RailsHelper.show_src
  show_src = ENV['RAILS_ENV'] == 'development' if show_src.nil?
  ## preprocessing
  if ::Erubis::Helpers::RailsHelper.preprocessing
    preprocessor = _create_preprocessor(template)
    template = preprocessor.evaluate(_preprocessing_context_object())
    logger.info "** Erubis: preprocessed==<<'END'\n#{template}END\n" if show_src
  end
  ## convert into ruby code
  src = klass.new(template, properties).src
  #src.insert(0, '_erbout = ')
  logger.info "** Erubis: src==<<'END'\n#{src}END\n" if show_src
  return src
end

#_create_preprocessor(template) ⇒ Object



108
109
110
# File 'lib/erubis/helpers/rails_helper.rb', line 108

def _create_preprocessor(template)
  return PreprocessingEruby.new(template, :escape=>true)
end

#_preprocessing_context_objectObject



111
112
113
# File 'lib/erubis/helpers/rails_helper.rb', line 111

def _preprocessing_context_object
  return self
end