Sha256: f10c56c862ed5d473003badadef7852ecfc43d049eb4f8bca7aadb2cbb723db5

Contents?: true

Size: 412 Bytes

Versions: 15

Compression:

Stored size: 412 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

15 entries across 15 versions & 1 rubygems

Version Path
ree-1.0.47 lib/ree/utils/render_utils.rb
ree-1.0.46 lib/ree/utils/render_utils.rb
ree-1.0.45 lib/ree/utils/render_utils.rb
ree-1.0.44 lib/ree/utils/render_utils.rb
ree-1.0.43 lib/ree/utils/render_utils.rb
ree-1.0.42 lib/ree/utils/render_utils.rb
ree-1.0.41 lib/ree/utils/render_utils.rb
ree-1.0.40 lib/ree/utils/render_utils.rb
ree-1.0.39 lib/ree/utils/render_utils.rb
ree-1.0.38 lib/ree/utils/render_utils.rb
ree-1.0.37 lib/ree/utils/render_utils.rb
ree-1.0.36 lib/ree/utils/render_utils.rb
ree-1.0.35 lib/ree/utils/render_utils.rb
ree-1.0.34 lib/ree/utils/render_utils.rb
ree-1.0.33 lib/ree/utils/render_utils.rb