Class: Lhj::ErbTemplateHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/lhj/helper/erb_template_helper.rb

Class Method Summary collapse

Class Method Details

.load(template_name) ⇒ Object



6
7
8
9
# File 'lib/lhj/helper/erb_template_helper.rb', line 6

def self.load(template_name)
  path = "#{Lhj::Config.instance.home_dir}/#{template_name}.erb"
  load_from_path(path)
end

.load_from_path(template_filepath) ⇒ Object



11
12
13
14
15
16
# File 'lib/lhj/helper/erb_template_helper.rb', line 11

def self.load_from_path(template_filepath)
  unless File.exist?(template_filepath)
    UI.user_error!("Could not find template at path '#{template_filepath}'")
  end
  File.read(template_filepath)
end

.render(template, template_vars_hash, trim_mode = nil) ⇒ Object



18
19
20
# File 'lib/lhj/helper/erb_template_helper.rb', line 18

def self.render(template, template_vars_hash, trim_mode = nil)
  Lhj::ErbalT.new(template_vars_hash, trim_mode).render(template)
end