Module: RackStep::Controller::ErbRendering

Defined in:
lib/controller.rb

Overview

A module for controllers to add ERB template rendering. RackStep is not meant to be used for template rendering. We recommend you to use a SPA (Single Page Application) approach. But if you want to, you may include this module into your controller and render ERB templates, following the old ruby web way. TODO: Add layout support.

Instance Method Summary collapse

Instance Method Details

#render_erb(template_name, erb_template_directory = 'app/public/pages') ⇒ Object



68
69
70
71
72
# File 'lib/controller.rb', line 68

def render_erb(template_name, erb_template_directory = 'app/public/pages')
  template_path = "#{erb_template_directory}/#{template_name}.erb"
  erb = ERB.new(File.open(template_path).read)
  return erb.result(binding)
end