Class: Hyde::Templates::ERB

Inherits:
Hyde::Template show all
Defined in:
lib/hyde/template/erb.rb

Overview

ERB Template language adapter

Instance Attribute Summary

Attributes inherited from Hyde::Template

#binding

Instance Method Summary collapse

Methods inherited from Hyde::Template

#local_variable_get, #local_variable_set, #local_variables, #override_locals

Constructor Details

#initialize(input, toplevel: nil, locals: nil) ⇒ ERB

Returns a new instance of ERB.

See Also:

  • Hyde::Template#new


11
12
13
14
# File 'lib/hyde/template/erb.rb', line 11

def initialize(input, toplevel: nil, locals: nil)
  super
  @template = ::ERB.new(@template)
end

Instance Method Details

#runObject

Run the template.



17
18
19
20
21
# File 'lib/hyde/template/erb.rb', line 17

def run
  @context.instance_exec(@template) do |template|
    template.result @binding
  end
end