Sha256: 998208cd4479a3774d4737e7f04aae86e73e09ee55b27231f75b33467c85bf0a

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 KB

Contents

module Locomotive
  module Plugin
    module Liquid
      # @api internal
      #
      # The methods shared by all tag subclasses.
      module TagSubclassMethods

        # Check to see if this tag is enabled in the liquid context and render
        # accordingly.
        #
        # @param context [Liquid::Context] the liquid context object
        # @return the rendered content of the superclass using +render+ or
        #         +render_disabled+ as appropriate
        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

        # The prefix for this tag.
        def prefix
          self.class.prefix
        end

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
locomotive_plugins-1.2.0 lib/locomotive/plugin/liquid/tag_subclass_methods.rb
locomotive_plugins-1.1.1 lib/locomotive/plugin/liquid/tag_subclass_methods.rb
locomotive_plugins-1.1.0 lib/locomotive/plugin/liquid/tag_subclass_methods.rb
locomotive_plugins-1.0.1 lib/locomotive/plugin/liquid/tag_subclass_methods.rb
locomotive_plugins-1.0.0.beta10 lib/locomotive/plugin/liquid/tag_subclass_methods.rb
locomotive_plugins-1.0.0.beta9 lib/locomotive/plugin/liquid/tag_subclass_methods.rb
locomotive_plugins-1.0.0.beta8 lib/locomotive/plugin/liquid/tag_subclass_methods.rb
locomotive_plugins-1.0.0.beta7 lib/locomotive/plugin/liquid/tag_subclass_methods.rb
locomotive_plugins-1.0.0.beta6 lib/locomotive/plugin/liquid/tag_subclass_methods.rb
locomotive_plugins-1.0.0.beta5 lib/locomotive/plugin/liquid/tag_subclass_methods.rb