Sha256: b1c47c58c1bfbeb8fd8dcd12575453a681dbdb94a052dba0b42eed6b5ec68950
Contents?: true
Size: 723 Bytes
Versions: 1
Compression:
Stored size: 723 Bytes
Contents
require 'erb' module Wright module Util # ERB renderer. # # @example # template = "foo is <%= foo %>." # hash = { foo: :bar } # Wright::Util::ErbRenderer.new(hash).render(template) # # => "foo is bar." class ErbRenderer 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 # Renders an ERB template. # @param template [String] the template # @return [String] the rendered template def render(template) ERB.new(template).result(binding) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wright-0.5.0 | lib/wright/util/erb_renderer.rb |