Sha256: d68dd5d322a1575d16bb3693ca6fe62a17dc7ee48de38f2c37e4a8bd27a10c21
Contents?: true
Size: 902 Bytes
Versions: 17
Compression:
Stored size: 902 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 ComfortableMexicanSofa::Content::Tag::Snippet < ComfortableMexicanSofa::Content::Tag attr_reader :identifier def initialize(context:, params: [], source: nil) super @identifier = params[0] unless @identifier.present? raise Error, "Missing identifier for snippet tag" end end def content snippet.content end # Grabbing or initializing Comfy::Cms::Snippet object def snippet context.site.snippets.detect { |s| s.identifier == identifier } || context.site.snippets.build(identifier: identifier) end end ComfortableMexicanSofa::Content::Renderer.register_tag( :snippet, ComfortableMexicanSofa::Content::Tag::Snippet )
Version data entries
17 entries across 17 versions & 6 rubygems