Class: MetaERB::Rails::Handler

Inherits:
ActionView::TemplateHandler
  • Object
show all
Includes:
ActionView::TemplateHandlers::Compilable
Defined in:
lib/meta_erb/rails/handler.rb

Instance Method Summary collapse

Instance Method Details

#compile(template) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/meta_erb/rails/handler.rb', line 18

def compile(template)
  meta_template = MetaERB::MetaTemplate.new(template.source, template.path)
  meta_templates[template.path] = meta_template
  src = "<% __in_erb_template=true ; @meta_template = MetaERB::Rails::Handler.meta_templates[#{template.path.inspect}] %>#{meta_template.evaluate}"
  src = ::ERB.new(src, nil, erb_trim_mode, '@output_buffer').src
  
  
  # Ruby 1.9 prepends an encoding to the source. However this is
  # useless because you can only set an encoding on the first line
  RUBY_VERSION >= '1.9' ? src.sub(/\A#coding:.*\n/, '') : src
end

#erb_trim_modeObject

:singleton-method: Specify trim mode for the ERB compiler. Defaults to ‘-’. See ERb documentation for suitable values.



12
# File 'lib/meta_erb/rails/handler.rb', line 12

cattr_accessor :erb_trim_mode