Sha256: 6f954d528c0b4e19b2459af159471a4406f821b7d2176767754b0928a35d1ff8
Contents?: true
Size: 933 Bytes
Versions: 10
Compression:
Stored size: 933 Bytes
Contents
# frozen_string_literal: true # Tag for reusable snippets within context's site scope. Looks like this: # {{cms:snippet identifier}} # Snippets may have more tags in them like fragments, so they may be expanded too. # class Occams::Content::Tag::Snippet < Occams::Content::Tag attr_reader :identifier def initialize(context:, params: [], source: nil) super @identifier = params[0] return if @identifier.present? raise Error, 'Missing identifier for snippet tag' end def content if snippet.markdown Kramdown::Document.new(snippet.content.to_s).to_html else snippet.content end end # Grabbing or initializing Occams::Cms::Snippet object def snippet context.site.snippets.detect { |s| s.identifier == identifier } || context.site.snippets.build(identifier: identifier) end end Occams::Content::Renderer.register_tag( :snippet, Occams::Content::Tag::Snippet )
Version data entries
10 entries across 10 versions & 1 rubygems