Module: Racket::Helpers::View

Defined in:
lib/racket/helpers/view.rb

Overview

Helper module that handles views

Instance Method Summary collapse

Instance Method Details

#render_template(template, context = self, template_settings = nil) ⇒ String|nil

TODO:

Allow user to specify template options

Renders a template file using the specified context.

Parameters:

  • template (String)
  • context (Object) (defaults to: self)

Returns:

  • (String|nil)


30
31
32
33
34
35
36
# File 'lib/racket/helpers/view.rb', line 30

def render_template(template, context = self, template_settings = nil)
  utils = Controller.context.utils
  template = utils.build_path(template)
  return nil unless Racket::Utils::FileSystem.file_readable?(template)
  settings = ::Racket::Utils::Views.extract_template_settings(context, template_settings)
  Tilt.new(template, nil, settings).render(context)
end