Sha256: f8bc1d4e3c0e49bdc5a4cd5cabc52d799bd997e486640d7c02aacd61e176babf
Contents?: true
Size: 621 Bytes
Versions: 3
Compression:
Stored size: 621 Bytes
Contents
class Grandstand::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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grandstand-0.3.0 | app/models/grandstand/template.rb |
grandstand-0.2.7 | app/models/grandstand/template.rb |
grandstand-0.2.6 | app/models/grandstand/template.rb |