Module: RedmineCLI::TemplateRenderer

Defined in:
lib/redmine_cli/template_renderer.rb

Overview

Renders templates

Defined Under Namespace

Classes: ErbEnvironment

Class Method Summary collapse

Class Method Details

.render(template, variables = {}) ⇒ Object

finds template and renders it

Parameters:

  • template (String, Symbol)

    name of template. Use ‘dir1/dir2/name’ means assets/templates/dir1/dir2/name.erb



18
19
20
21
22
23
# File 'lib/redmine_cli/template_renderer.rb', line 18

def self.render(template, variables = {})
  path = File.expand_path(template.to_s, @template_directory) + '.erb'
  fail "Template not found: #{path}" unless File.exist? path

  ErbEnvironment.new(File.read(path), variables).render
end