Sha256: d93a64a87d93b635912783a85f3bb33d0facd6d5195f1e538c29d840116d6c29

Contents?: true

Size: 459 Bytes

Versions: 3

Compression:

Stored size: 459 Bytes

Contents

# code:
# * George Moschovitis  <gm@navel.gr>
#
# (c) 2004 Navel, all rights reserved.
# $Id$

module N;

# = Template
#
# A simple templating mechanism.
#
class Template
	attr_accessor :body
	
	#
	#
	def initialize(filename)
		@body = File.read(filename)
	end
	
	# Apply the substitutions to the template.
	#
	def gsub(hash)
		res = body.dup()
		
		hash.each {|k, v|
			res.gsub!(k, v)
		}
		
		return res
	end
	alias_method :render, :gsub
end

end # module

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nitro-0.2.0 lib/n/utils/template.rb
nitro-0.3.0 lib/n/utils/template.rb
nitro-0.4.1 lib/nitro/utils/template.rb