Module: Mvnizer::Erbicole
- Included in:
- Project
- Defined in:
- lib/mvnizer/erb_helper.rb
Overview
ERB utilities that needs to be brought into a class used as an ERB binding.
Constant Summary collapse
- TEMPLATE_PATH =
Path to folder storing all templates.
File.join(File.dirname(__FILE__), 'templates')
Instance Method Summary collapse
-
#get_binding ⇒ Object
Return the ERB binding.
-
#render(name, object = nil) ⇒ Object
Renders a template named ‘name` located in the templates folder.
Instance Method Details
#get_binding ⇒ Object
Return the ERB binding.
23 24 25 |
# File 'lib/mvnizer/erb_helper.rb', line 23 def get_binding binding end |
#render(name, object = nil) ⇒ Object
Renders a template named ‘name` located in the templates folder.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/mvnizer/erb_helper.rb', line 11 def render(name, object = nil) binding = get_binding if object.respond_to?(:get_binding) binding = object.get_binding end content = File.read(File.join(TEMPLATE_PATH, name)) ERB.new(content).result(binding) end |