Class: Hyde::Templates::ERB
- Inherits:
-
Hyde::Template
- Object
- Hyde::Template
- Hyde::Templates::ERB
- Defined in:
- lib/hyde/template/erb.rb
Overview
ERB Template language adapter
Instance Method Summary collapse
-
#initialize(input, vars = nil, parent:) ⇒ ERB
constructor
A new instance of ERB.
-
#run ⇒ Object
Run the template.
Methods inherited from Hyde::Template
#import, #local_variable_get, #local_variable_set, #local_variables, #override_locals
Constructor Details
#initialize(input, vars = nil, parent:) ⇒ ERB
Returns a new instance of ERB.
11 12 13 14 15 16 17 18 19 |
# File 'lib/hyde/template/erb.rb', line 11 def initialize(input, vars = nil, parent:) super varname = "_part_#{SecureRandom.hex(10)}".to_sym while @binding.local_variable_defined? varname varname = "_part_#{SecureRandom.hex(10)}".to_sym end @template = ::ERB.new(@template, eoutvar: varname) @template.filename = input.is_a?(File) ? input.path : "(Inline)" end |
Instance Method Details
#run ⇒ Object
Run the template.
22 23 24 |
# File 'lib/hyde/template/erb.rb', line 22 def run @template.result @binding end |