Sha256: b68d2ce966b515c279f9f7867e75bef64c78821922b2e2cf6c756cc21749144b

Contents?: true

Size: 1.01 KB

Versions: 16

Compression:

Stored size: 1.01 KB

Contents

#------------------------------------------------------------------------------
module Liquid
  class Snippet < DmCore::LiquidTag
    include DmCore::AccountHelper
    include DmCore::LiquidHelper
    
    #------------------------------------------------------------------------------
    def render(context)
      output = ''
      if @attributes['slug'].present?
        cms_snippet = CmsSnippet.find_by_slug(@attributes['slug'])
        if cms_snippet
          output = context.registers[:view].render_content_item(cms_snippet)          
        end
      end
      return output
    end

    #------------------------------------------------------------------------------
    def self.details
      { name: self.tag_name,
        summary: 'Display a snippet',
        category: 'structure',
        description: <<-END_OF_DESCRIPTION
Output the content of a snippet specified by the slug

~~~
{% snippet slug: 'some-snippet-slug'}
~~~

END_OF_DESCRIPTION
      }
    end
  end
  Template.register_tag('snippet', Snippet)
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dm_cms-4.2.3.10 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.3.9 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.3.8 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.3.7 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.3.6 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.3.5 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.3.4 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.3.3 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.3.2 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.3.1 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.3 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.2.3 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.2.2 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.2.1 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.2 lib/dm_cms/liquid/tags/snippet.rb
dm_cms-4.2.1.5 lib/dm_cms/liquid/tags/snippet.rb