Sha256: 50105443e4bbadef5c3473fc6f17ee3cc3f21caf9c666e143cac9dc9a11d67e6

Contents?: true

Size: 654 Bytes

Versions: 21

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders an announcement
  # the `model` is spected to be a Hash with two keys:
  #  `announcement` is mandatory, its the message to show
  #  `callout_class` is optional, the css class modifier
  #
  # {
  #   announcement: { ... },
  #   callout_class: "warning"
  # }
  #
  class AnnouncementCell < Decidim::ViewModel
    include Decidim::SanitizeHelper

    def show
      return unless announcement.presence
      render :show
    end

    private

    def callout_class
      model[:callout_class] ||= "secondary"
    end

    def announcement
      model[:announcement]
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
decidim-core-0.12.0.pre app/cells/decidim/announcement_cell.rb