Sha256: ac3bcf5323347eab7db7a8b7712302d4b0d3c1c7f7a9f30300a2c87cbb4564ab
Contents?: true
Size: 654 Bytes
Versions: 22
Compression:
Stored size: 654 Bytes
Contents
class Template @_cache = {} def self.[](name) @_cache[name] || @_cache["templates/#{name}"] end def self.[]=(name, instance) @_cache[name] = instance end def self.paths @_cache.keys end attr_reader :body def initialize(name, &body) @name, @body = name, body Template[name] = self end def inspect "#<Template: '#{@name}'>" end def render(ctx = self) ctx.instance_exec(OutputBuffer.new, &@body) end class OutputBuffer def initialize @buffer = [] end def append(str) @buffer << str end def join @buffer.join end alias append= append end end
Version data entries
22 entries across 22 versions & 1 rubygems