Class: N::Template

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

Overview

Template

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Template

Returns a new instance of Template.



20
21
22
# File 'lib/n/utils/template.rb', line 20

def initialize(filename)
	@body = File.read(filename)
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



16
17
18
# File 'lib/n/utils/template.rb', line 16

def body
  @body
end

Instance Method Details

#gsub(hash) ⇒ Object Also known as: render

Apply the substitutions to the template.



26
27
28
29
30
31
32
33
34
# File 'lib/n/utils/template.rb', line 26

def gsub(hash)
	res = body.dup()
	
	hash.each {|k, v|
		res.gsub!(k, v)
	}
	
	return res
end