Module: Middleman::Extensions
- Defined in:
- lib/middleman-core/extensions.rb
Class Method Summary collapse
- .load(name) ⇒ Object
-
.register(name, namespace = nil) { ... } ⇒ Object
Register a new extension.
- .registered ⇒ Object
Class Method Details
.load(name) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/middleman-core/extensions.rb', line 37 def load(name) name = name.to_sym return nil unless registered.has_key?(name) extension = registered[name] if extension.is_a?(Proc) extension = extension.call() || nil registered[name] = extension end extension end |
.register(name, namespace = nil) { ... } ⇒ Object
Register a new extension. Choose a name which will be used to activate the extension in config.rb, like this:
activate :my_extension
Provide your extension module either as the namespace parameter, or return it from the block:
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/middleman-core/extensions.rb', line 24 def register(name, namespace=nil, &block) # If we've already got a matching extension that passed the # version check, bail out. return if registered.has_key?(name.to_sym) && !registered[name.to_sym].is_a?(String) registered[name.to_sym] = if block_given? block elsif namespace namespace end end |
.registered ⇒ Object
6 7 8 |
# File 'lib/middleman-core/extensions.rb', line 6 def registered @_registered ||= {} end |