class Wright::Util::ErbRenderer

ERB renderer.

@example

template = "foo is <%= foo %>."
hash = { foo: :bar }
Wright::Util::ErbRenderer.new(hash).render(template)
# => "foo is bar."

Public Class Methods

new(hash) click to toggle source
# File lib/wright/util/erb_renderer.rb, line 13
def initialize(hash)
  hash.each do |k, v|
    instance_var = "@#{k}"
    instance_variable_set(instance_var, v)
    define_singleton_method(k) { instance_variable_get(instance_var) }
  end
end

Public Instance Methods

render(template) click to toggle source

Renders an ERB template. @param template [String] the template @return [String] the rendered template

# File lib/wright/util/erb_renderer.rb, line 24
def render(template)
  ERB.new(template).result(binding)
end