Class: Grandstand::Template
- Inherits:
-
Object
- Object
- Grandstand::Template
- Defined in:
- app/models/grandstand/template.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, body = nil) ⇒ Template
constructor
A new instance of Template.
- #path ⇒ Object
- #render ⇒ Object
Constructor Details
#initialize(name, body = nil) ⇒ Template
15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/grandstand/template.rb', line 15 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 |
Class Method Details
.[](name) ⇒ Object
3 4 5 6 |
# File 'app/models/grandstand/template.rb', line 3 def [](name) @templates ||= {} @templates[name] ||= new(name) end |
Instance Method Details
#path ⇒ Object
26 27 28 |
# File 'app/models/grandstand/template.rb', line 26 def path @file.freeze end |
#render ⇒ Object
30 31 32 |
# File 'app/models/grandstand/template.rb', line 30 def render @body.freeze end |