Sha256: 975bf252309a3c3cc18a5d2113481bbb4c0f7e19dd81d9487de637b926eb770d
Contents?: true
Size: 736 Bytes
Versions: 58
Compression:
Stored size: 736 Bytes
Contents
# frozen_string_literal: true module Decidim # A utility for managing snippets that need to be registered during the view # display and displayed in another part of the application. For example, maps # can register their snippets when the map is displayed but they need to be # added to the <head> section of the document. class Snippets def initialize @snippets = {} end def add(category, *snippet) @snippets[category] ||= [] @snippets[category].push(*snippet.flatten) end def for(category) @snippets[category] end def any?(category) self.for(category).present? end def display(category) self.for(category)&.join("\n")&.html_safe end end end
Version data entries
58 entries across 58 versions & 1 rubygems