Sha256: 25fa33fb55cfe69ba32494960f8133d86f19909634515923badc689dfdb0d90c
Contents?: true
Size: 657 Bytes
Versions: 3
Compression:
Stored size: 657 Bytes
Contents
module Space class View class Template class << self def [](path) templates[path] ||= ERB.new(File.read(path), nil, '%<>-') end def templates @templates ||= {} end end include Helpers attr_reader :template def initialize(path) @template = Template[path] end def render(assigns) assigns.each { |key, value| assign(key, value) } template.result(binding) end def assign(key, value) instance_variable_set(:"@#{key}", value) (class << self; self; end).send(:attr_reader, key) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
space-0.0.9 | lib/space/view/template.rb |
space-0.0.8 | lib/space/view/template.rb |
space-0.0.7 | lib/space/view/template.rb |