Sha256: b9c646efcd4f3a41f64944414baab5b25702d1b77318007ebefce26be64ece5c

Contents?: true

Size: 662 Bytes

Versions: 2

Compression:

Stored size: 662 Bytes

Contents

require 'erb'
require 'ostruct'

class Sfp::Template < OpenStruct
	def render(template)
		ERB.new(template).result(binding)
	end

	def render_to_file(template, file)
		result = render(template)
		File.open(file, 'w+') { |f| f.write(result) }
	end

	def render_file(file)
		render_to_file(File.read(file), file)
	end

	def self.render(template, map)
		renderer = ::Sfp::Template.new(map)
		renderer.render(template)
	end

	def self.render_to_file(template, file, map)
		renderer = ::Sfp::Template.new(map)
		renderer.render_to_file(template, file)
	end

	def self.render_file(file, map)
		renderer = ::Sfp::Template.new(map)
		renderer.render_file(file)
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sfpagent-0.3.4 lib/sfpagent/template.rb
sfpagent-0.3.3 lib/sfpagent/templateEngine.rb