Module: Locomotive::Plugin::ClassMethods

Defined in:
lib/locomotive/plugin.rb

Instance Method Summary collapse

Instance Method Details

#default_plugin_idObject

Override this method to specify the default plugin_id to use when Locomotive registers the plugin. This plugin_id may be overridden by Locomotive CMS.

Returns:

  • by default, the underscored plugin class name (without the namespace)



53
54
55
# File 'lib/locomotive/plugin.rb', line 53

def default_plugin_id
  to_s.split('::').last.underscore
end

#javascript_contextObject

Override this method to specify ruby objects accessable via the global javascript context. The return value must be a hash whoes keys are the variable names and the values are the objects. The objects will be included in the global context after being prefixed with the plugin_id.

Note:

therubyracer is not able to execute class methods so please ensure
that the objects you pass in are not classes.


118
119
120
# File 'lib/locomotive/plugin.rb', line 118

def javascript_context
  {}
end

#liquid_filtersObject

Override this method to provide a module or array of modules to include as liquid filters in the site. All public methods in the module will be included as filters after being prefixed with the plugin id (#{plugin_id}_#{method_name}).

Examples:

class MyPlugin
  def self.liquid_filters
    [ MyFilters, MoreFilters ]
  end
end


68
69
70
# File 'lib/locomotive/plugin.rb', line 68

def liquid_filters
  nil
end

#liquid_tagsObject

Override this method to specify the liquid tags supplied by this plugin. The return value must be a hash whose keys are the tag names and values are the tag classes. The tag names will be included in Locomotive’s liquid renderer after being prefixed with the plugin id (#{plugin_id}_#{tag_name}).

Examples:

class MyPlugin
  def self.liquid_tags
    { :my_tag => MyTag, :other_tag => OtherTag }
  end
end


84
85
86
# File 'lib/locomotive/plugin.rb', line 84

def liquid_tags
  {}
end

#plugin_loadedObject

Override this method to provide functionality which will be executed when the CMS starts up and loads all plugins.



90
91
# File 'lib/locomotive/plugin.rb', line 90

def plugin_loaded
end

#rack_appObject

Override this method to supply a rack app to be used for handling requests. Locomotive CMS will mount this app on a path dependent on the plugin_id. See RackAppHelpers for some helper methods.



96
97
98
# File 'lib/locomotive/plugin.rb', line 96

def rack_app
  nil
end