Module: Locomotive::Plugin::Liquid::TagSubclassMethods

Defined in:
lib/locomotive/plugin/liquid/tag_subclass_methods.rb

Overview

The methods shared by all tag subclasses.

Instance Method Summary collapse

Instance Method Details

#prefixObject

The prefix for this tag.



36
37
38
# File 'lib/locomotive/plugin/liquid/tag_subclass_methods.rb', line 36

def prefix
  self.class.prefix
end

#render(context) ⇒ Object

Check to see if this tag is enabled in the liquid context and render accordingly.

Parameters:

  • context (Liquid::Context)

    the liquid context object

Returns:

  • the rendered content of the superclass using render or render_disabled as appropriate



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/locomotive/plugin/liquid/tag_subclass_methods.rb', line 16

def render(context)
  enabled_tags = context.registers[:enabled_plugin_tags]
  enabled = enabled_tags && enabled_tags.include?(self.class)

  output = nil

  ContextHelpers.add_plugin_object_to_context(self.prefix, context) do
    output = if enabled
      super
    elsif self.respond_to?(:render_disabled)
      self.render_disabled(context)
    else
      ''
    end
  end

  output
end