Sha256: e3dd4e600bb2ebf888910d4ce1ba7bf18d08d41a465ff5716ba9e338e171477f
Contents?: true
Size: 468 Bytes
Versions: 10
Compression:
Stored size: 468 Bytes
Contents
require 'erb' module RakeTemplate class Template def self.from_file(path) new(File.read(path)) end def initialize(contents) @contents = contents end def render(parameters = {}) context = Object.new parameters.each do |key, value| context.instance_variable_set("@#{key}", value) end context_binding = context.instance_eval {binding} ERB.new(@contents).result(context_binding) end end end
Version data entries
10 entries across 10 versions & 1 rubygems