Module: Locomotive::Plugin::Liquid::ContextHelpers
- Defined in:
- lib/locomotive/plugin/liquid/context_helpers.rb
Overview
Adds the plugin object to the liquid context.
Class Method Summary collapse
-
.add_plugin_object_to_context(plugin_id, context) ⇒ Object
Adds the plugin object to the liquid context object to be used by tags, filters, and drops.
Class Method Details
.add_plugin_object_to_context(plugin_id, context) ⇒ Object
Adds the plugin object to the liquid context object to be used by tags, filters, and drops. This method looks in the :site
register for an object which responds to #plugin_object_for_id
in order to populate the :plugin_object
register. If such an object does not exist, the method simply yields without altering the context object. Otherwise, after yielding, the context object is reset to its previous state.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/locomotive/plugin/liquid/context_helpers.rb', line 20 def self.add_plugin_object_to_context(plugin_id, context) site = self.fetch_site(context) if site old = context.registers[:plugin_object] obj = site.plugin_object_for_id(plugin_id) context.registers[:plugin_object] = obj yield context.registers[:plugin_object] = old else yield end end |