Class: Padrino::Rendering::ErubisTemplate Private

Inherits:
Tilt::ErubisTemplate
  • Object
show all
Defined in:
lib/padrino/rendering/erubis_template.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Modded ErubisTemplate that doesn’t insist in an String as output buffer.

Instance Method Summary collapse

Instance Method Details

#precompiled_preamble(locals) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

In preamble we need a flag ‘__in_erb_template` and SafeBuffer for padrino apps.



53
54
55
56
57
# File 'lib/padrino/rendering/erubis_template.rb', line 53

def precompiled_preamble(locals)
  original = super
  return original unless @is_padrino_app
  "__in_erb_template = true\n" << original.rpartition("\n").first << "#{@outvar} = _buf = SafeBuffer.new\n"
end

#render(*args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
45
46
47
48
# File 'lib/padrino/rendering/erubis_template.rb', line 42

def render(*args)
  app       = args.first
  app_class = app.class
  @is_padrino_app = (defined?(Padrino::Application) && app.kind_of?(Padrino::Application)) || 
                    (app_class.respond_to?(:erb) && app_class.erb[:engine_class] == Padrino::Rendering::SafeEruby)
  super
end