Sha256: 434de56dca87566e4534ee4d30bea90094cb16fe0833325d187b377e95599da5
Contents?: true
Size: 608 Bytes
Versions: 4
Compression:
Stored size: 608 Bytes
Contents
class Template class << self def [](name) @templates ||= {} @templates[name] ||= new(name) end protected def method_missing(*args) method = args.shift.to_sym self[method].render end end def initialize(name, body = nil) @file = Dir[*ApplicationController.view_paths.map {|path| File.join(path.to_s, 'shared', "#{name}.html")}].find {|file| File.file?(file)} if body @body = body elsif @file @body = File.read(@file) else return false end end def path @file.freeze end def render @body.freeze end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
grandstand-0.2.4 | app/models/template.rb |
grandstand-0.2.3 | app/models/template.rb |
grandstand-0.2.2 | app/models/template.rb |
grandstand-0.2.1 | app/models/template.rb |