module Mvnizer::Erbicole

ERB utilities that needs to be brought into a class used as an ERB binding.

Constants

TEMPLATE_PATH

Path to folder storing all templates.

Public Instance Methods

get_binding() click to toggle source

Return the ERB binding.

# File lib/mvnizer/erb_helper.rb, line 23
def get_binding
  binding
end
render(name, object = nil) click to toggle source

Renders a template named ‘name` located in the templates folder.

# 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