Class: Middleman::Renderers::ERb::Template

Inherits:
Tilt::ErubiTemplate
  • Object
show all
Defined in:
lib/middleman-core/renderers/erb.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ Template

Returns a new instance of Template.



10
11
12
13
14
# File 'lib/middleman-core/renderers/erb.rb', line 10

def initialize(*args, &block)
  super

  @context = @options[:context]
end

Instance Method Details

#precompiled_preamble(locals) ⇒ Object

In preamble we need a flag __in_erb_template for padrino apps.



19
20
21
22
# File 'lib/middleman-core/renderers/erb.rb', line 19

def precompiled_preamble(locals)
  original = super
  "__in_erb_template = true\n" << original
end

#precompiled_template(locals) ⇒ Object

Force the template the use the configured encoding.



27
28
29
30
31
32
33
# File 'lib/middleman-core/renderers/erb.rb', line 27

def precompiled_template(locals)
  if @context
    super.dup.force_encoding(@context.app.config[:encoding])
  else
    super
  end
end