Sha256: ec4d6fc0644d0b32c07391286d1927aa82f23427b1c238b4255130a954232f11
Contents?: true
Size: 998 Bytes
Versions: 1
Compression:
Stored size: 998 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 ComfortableMediaSurfer::Content::Tags::Snippet < ComfortableMediaSurfer::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 Comfy::Cms::Snippet object def snippet context.site.snippets.detect { |s| s.identifier == identifier } || context.site.snippets.build(identifier: identifier) end end ComfortableMediaSurfer::Content::Renderer.register_tag( :snippet, ComfortableMediaSurfer::Content::Tags::Snippet )
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comfortable_media_surfer-3.0.0 | lib/comfortable_media_surfer/content/tags/snippet.rb |