class Makanai::TemplateEngine::Erb

Attributes

locals[R]
text[R]

Public Class Methods

new(text:, locals: {}) click to toggle source
Calls superclass method
# File lib/makanai/template_engine/erb.rb, line 10
def initialize(text:, locals: {})
  super()
  @text = text
  @locals = locals
end

Public Instance Methods

result() click to toggle source
# File lib/makanai/template_engine/erb.rb, line 18
def result
  # NOTE: ERB is need to pass the binding.
  # So, pass the binding of the object that defined the instance variable.
  # ref: https://docs.ruby-lang.org/en/2.7.0/ERB.html#method-i-result
  ERB.new(text).result(Locals.new(locals).self_binding)
end