Class: FlavourSaver::Partial
- Inherits:
-
Object
- Object
- FlavourSaver::Partial
- Defined in:
- lib/flavour_saver/partial.rb
Class Method Summary collapse
- .fetch(name) ⇒ Object
- .partials ⇒ Object
- .register_partial(name, content = nil, &block) ⇒ Object
- .reset_partials ⇒ Object
Class Method Details
.fetch(name) ⇒ Object
22 23 24 25 26 |
# File 'lib/flavour_saver/partial.rb', line 22 def self.fetch(name) p = partials[name.to_s] raise UnknownPartialException, "I can't find the partial named #{name.inspect}" unless p p end |
.partials ⇒ Object
18 19 20 |
# File 'lib/flavour_saver/partial.rb', line 18 def self.partials @partials ||= {} end |
.register_partial(name, content = nil, &block) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/flavour_saver/partial.rb', line 6 def self.register_partial(name, content=nil, &block) if block.respond_to? :call partials[name.to_s] = block else partials[name.to_s] = Parser.parse(Lexer.lex(content)) end end |
.reset_partials ⇒ Object
14 15 16 |
# File 'lib/flavour_saver/partial.rb', line 14 def self.reset_partials @partials = {} end |