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

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

Instance Method Summary collapse

Instance Method Details

#_convert_template(template) ⇒ Object

covert eRuby string into ruby code



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

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



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

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

#_logger_info(message) ⇒ Object



113
114
115
# File 'lib/erubis/helpers/rails_helper.rb', line 113

def _logger_info(message)
  logger.info message
end

#_preprocessing_context_objectObject



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

def _preprocessing_context_object
  return self
end