Class: Ree::TemplateRenderer
- Defined in:
- lib/ree/templates/template_renderer.rb
Constant Summary collapse
- TEMPLATE_VARIABLE =
/<%=\s*([\w\d-]+)\s*%>/i
Class Method Summary collapse
Instance Method Summary collapse
- #get_undefined_variables ⇒ Object
- #handle ⇒ Object
-
#initialize(template, locals) ⇒ TemplateRenderer
constructor
A new instance of TemplateRenderer.
Constructor Details
#initialize(template, locals) ⇒ TemplateRenderer
Returns a new instance of TemplateRenderer.
14 15 16 17 18 |
# File 'lib/ree/templates/template_renderer.rb', line 14 def initialize(template, locals) @template = template @locals = locals @undefined_variables = [] end |
Class Method Details
.get_undefined_variables(template, locals = {}) ⇒ Object
9 10 11 |
# File 'lib/ree/templates/template_renderer.rb', line 9 def get_undefined_variables(template, locals = {}) Ree::TemplateRenderer.new(template, locals).get_undefined_variables end |
.handle(template, locals = {}) ⇒ Object
5 6 7 |
# File 'lib/ree/templates/template_renderer.rb', line 5 def handle(template, locals = {}) Ree::TemplateRenderer.new(template, locals).handle end |
Instance Method Details
#get_undefined_variables ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ree/templates/template_renderer.rb', line 26 def get_undefined_variables Ree::RenderUtils.render(@template, @locals) @undefined_variables rescue NameError => e raise NoMethodError, "Undefined method for template. Please, add :#{e.name} method to .ree/helpers/render_helper.rb file!" if @undefined_variables.include?(e.name) @locals[e.name] = e.name.to_s @undefined_variables.push(e.name) retry end |