Class: Typelizer::Renderer
- Inherits:
-
Object
- Object
- Typelizer::Renderer
- Defined in:
- lib/typelizer/renderer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(**context) ⇒ Object
-
#initialize(template) ⇒ Renderer
constructor
A new instance of Renderer.
Constructor Details
#initialize(template) ⇒ Renderer
Returns a new instance of Renderer.
11 12 13 |
# File 'lib/typelizer/renderer.rb', line 11 def initialize(template) @erb = ERB.new(File.read(File.join(File.dirname(__FILE__), "templates/#{template}")), trim_mode: "-") end |
Class Method Details
.call(template, **context) ⇒ Object
7 8 9 |
# File 'lib/typelizer/renderer.rb', line 7 def self.call(template, **context) new(template).call(**context) end |
Instance Method Details
#call(**context) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/typelizer/renderer.rb', line 15 def call(**context) b = binding context.each_pair do |key, value| b.local_variable_set(key, value) end erb.result(b) end |