Module: AmberComponent::TemplateHandler

Defined in:
lib/amber_component/template_handler.rb,
lib/amber_component/template_handler/erb.rb

Overview

Provides code which handles rendering different template languages.

Defined Under Namespace

Classes: ERB

Class Method Summary collapse

Class Method Details

.render_from_string(context, content, type, block = nil) ⇒ String

Parameters:

  • context (AmberComponent::Base)
  • content (String)
  • type (Symbol, String)
  • block (Proc, nil) (defaults to: nil)

Returns:

  • (String)


13
14
15
16
17
18
19
20
21
# File 'lib/amber_component/template_handler.rb', line 13

def render_from_string(context, content, type, block = nil)
  options = if type.to_sym == :erb
              { engine_class: ERB }
            else
              {}
            end

  ::Tilt[type].new(options) { content }.render(context, &block)
end