Class: Lore::GUI::ERB_Template

Inherits:
Object
  • Object
show all
Defined in:
lib/lore/gui/erb_template.rb

Instance Method Summary collapse

Constructor Details

#initialize(template_path, param_hash = {}, from = :backend) ⇒ ERB_Template

Returns a new instance of ERB_Template.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/lore/gui/erb_template.rb', line 36

def initialize(template_path, param_hash={}, from=:backend)

  @logger = Lore.logger
  
  @template = ''      
  IO.foreach(Lore.path + 'lore/gui/erb_template_helpers.rhtml') { |line|
    @template << line
  }
  template_path = template_path.to_s << '.rhtml' if template_path.instance_of? Symbol
  IO.foreach(Lore.path + 'lore/gui/templates/' << template_path) { |line|
    @template << line
  }
  
  @logger.debug('Template: ' << template_path)
  
  @erb = ERB.new(@template)

  @binding = binding_for(ERB_Binding_Params.new(param_hash))
  
end

Instance Method Details



65
66
67
# File 'lib/lore/gui/erb_template.rb', line 65

def print
  puts @erb.result(@binding)
end

#set_data(param_hash) ⇒ Object



57
58
59
# File 'lib/lore/gui/erb_template.rb', line 57

def set_data(param_hash)
  @binding = binding_for(ERB_Binding_Params.new(param_hash))
end

#stringObject



61
62
63
# File 'lib/lore/gui/erb_template.rb', line 61

def string
  @erb.result(@binding)
end