module Middleman::Extensions
Public Class Methods
load(name)
click to toggle source
# 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, &block)
click to toggle source
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:
@param [Symbol] name The name of the extension @param [Module] namespace The extension module @yield Instead of passing a module in namespace, you can provide
a block which returns your extension module. This gives you the ability to require other files only when the extension is activated.
# 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()
click to toggle source
# File lib/middleman-core/extensions.rb, line 6 def registered @_registered ||= {} end