Module: Railspack::TemplateHelper

Defined in:
lib/railspack/template_helper.rb

Class Method Summary collapse

Class Method Details

.get_from_file(template_name) ⇒ Object

Given a template_name, looks in the templates/ directory and returns the contents of the file.



5
6
7
8
9
# File 'lib/railspack/template_helper.rb', line 5

def self.get_from_file(template_name)
  template_path = File.join(File.dirname(__FILE__), 'templates', template_name)
  file = File.open(template_path, "rb")
  contents = file.read
end

.render(template_name, locals) ⇒ Object



11
12
13
14
# File 'lib/railspack/template_helper.rb', line 11

def self.render(template_name, locals)
  contents = TemplateHelper.get_from_file(template_name)
  Erubis::Eruby.new(contents).result(locals)
end