Class: Kanrisuru::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/kanrisuru/template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, args = {}) ⇒ Template

Returns a new instance of Template.



9
10
11
12
13
14
15
16
# File 'lib/kanrisuru/template.rb', line 9

def initialize(path, args = {})
  @path = path
  @trim_mode = '-'

  args.each do |variable_name, value|
    instance_variable_set("@#{variable_name}", value)
  end
end

Instance Attribute Details

#trim_mode=(value) ⇒ Object (writeonly)

Sets the attribute trim_mode

Parameters:

  • value

    the value to set the attribute trim_mode to.



7
8
9
# File 'lib/kanrisuru/template.rb', line 7

def trim_mode=(value)
  @trim_mode = value
end

Instance Method Details

#readObject



22
23
24
# File 'lib/kanrisuru/template.rb', line 22

def read
  StringIO.new(render)
end

#renderObject



18
19
20
# File 'lib/kanrisuru/template.rb', line 18

def render
  erb.result(binding)
end