class ComfortableMexicanSofa::Content::Tag::Snippet
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.
Attributes
identifier[R]
Public Class Methods
new(context:, params: [], source: nil)
click to toggle source
Calls superclass method
ComfortableMexicanSofa::Content::Tag::new
# File lib/comfortable_mexican_sofa/content/tags/snippet.rb, line 11 def initialize(context:, params: [], source: nil) super @identifier = params[0] unless @identifier.present? raise Error, "Missing identifier for snippet tag" end end
Public Instance Methods
content()
click to toggle source
# File lib/comfortable_mexican_sofa/content/tags/snippet.rb, line 20 def content snippet.content end
snippet()
click to toggle source
Grabbing or initializing Comfy::Cms::Snippet object
# File lib/comfortable_mexican_sofa/content/tags/snippet.rb, line 25 def snippet context.site.snippets.detect { |s| s.identifier == identifier } || context.site.snippets.build(identifier: identifier) end