Class: Rdm::Utils::RenderUtil
- Inherits:
-
Object
- Object
- Rdm::Utils::RenderUtil
- Defined in:
- lib/rdm/utils/render_util.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(locals = {}) ⇒ RenderUtil
constructor
A new instance of RenderUtil.
- #render(template) ⇒ Object
Constructor Details
#initialize(locals = {}) ⇒ RenderUtil
Returns a new instance of RenderUtil.
11 12 13 14 |
# File 'lib/rdm/utils/render_util.rb', line 11 def initialize(locals = {}) @render_binding = binding @locals = locals end |
Class Method Details
Instance Method Details
#render(template) ⇒ Object
16 17 18 19 20 |
# File 'lib/rdm/utils/render_util.rb', line 16 def render(template) @locals.each { |variable, value| @render_binding.local_variable_set(variable, value) } ERB.new(template).result(@render_binding) end |