Class: Clerq::Services::RenderErb

Inherits:
Service
  • Object
show all
Defined in:
lib/clerq/services/render_erb.rb

Overview

Render @object trough ERB temlate

Usage

erb = "id: <%= @object.id %>\ntitle: <%= @object.title %>\n"
obj = Node.new(id: 'uc', title: 'Use Cases', meta: {skip_meta: true})
txt = RenderErb.call(erb, obj) # or RenderErb.(erb, obj)

Instance Method Summary collapse

Methods inherited from Service

call

Constructor Details

#initialize(erb:, object:) ⇒ RenderErb

Returns a new instance of RenderErb.



22
23
24
25
# File 'lib/clerq/services/render_erb.rb', line 22

def initialize(erb: , object: )
  @erb = erb
  @object = object
end

Instance Method Details

#callObject



17
18
19
20
# File 'lib/clerq/services/render_erb.rb', line 17

def call
  tt = ERB.new(@erb, nil, "-")
  tt.result(binding)
end