Sha256: f386c5782436e554740b98567c2fdde62524532b0387d7f871c9d929025fde9f

Contents?: true

Size: 414 Bytes

Versions: 33

Compression:

Stored size: 414 Bytes

Contents

# frozen_string_literal  = true

require 'erb'

class Ree::RenderUtils
  def self.render(template, locals)
    new(locals).render(template)
  end

  def initialize(locals = {})
    @render_binding = binding
    @locals         = locals
  end

  def render(template)
    @locals.each { |variable, value| @render_binding.local_variable_set(variable, value) }

    ERB.new(template).result(@render_binding)
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
ree-1.0.32 lib/ree/utils/render_utils.rb
ree-1.0.31 lib/ree/utils/render_utils.rb
ree-1.0.30 lib/ree/utils/render_utils.rb
ree-1.0.29 lib/ree/utils/render_utils.rb
ree-1.0.28 lib/ree/utils/render_utils.rb
ree-1.0.27 lib/ree/utils/render_utils.rb
ree-1.0.26 lib/ree/utils/render_utils.rb
ree-1.0.25 lib/ree/utils/render_utils.rb
ree-1.0.24 lib/ree/utils/render_utils.rb
ree-1.0.23 lib/ree/utils/render_utils.rb
ree-1.0.22 lib/ree/utils/render_utils.rb
ree-1.0.21 lib/ree/utils/render_utils.rb
ree-1.0.20 lib/ree/utils/render_utils.rb
ree-1.0.19 lib/ree/utils/render_utils.rb
ree-1.0.18 lib/ree/utils/render_utils.rb
ree-1.0.17 lib/ree/utils/render_utils.rb
ree-1.0.16 lib/ree/utils/render_utils.rb
ree-1.0.15 lib/ree/utils/render_utils.rb
ree-1.0.14 lib/ree/utils/render_utils.rb
ree-1.0.13 lib/ree/utils/render_utils.rb