Module: Decidim::OrganizationHelper

Includes:
TranslatableAttributes
Included in:
ApplicationMailer, Events::SimpleEvent, LayoutHelper
Defined in:
app/helpers/decidim/organization_helper.rb

Overview

View helpers related to the organization.

Instance Method Summary collapse

Methods included from TranslatableAttributes

#default_locale?

Instance Method Details

#current_organization_nameObject



43
44
45
# File 'app/helpers/decidim/organization_helper.rb', line 43

def current_organization_name
  organization_name(current_organization)
end

#organization_colorsObject

Renders a view with the customizable CSS variables in two flavours:

  1. as a hexadecimal valid CSS color (ie: #ff0000)

  2. as a disassembled RGB components (ie: 255 0 0)

Example:

–primary: #ff0000; –primary-rgb: 255 0 0

Hexadecimal variables can be used as a normal CSS color:

color: var(–primary)

While the disassembled variant can be used where you need to manipulate the color somehow (ie: adding a background transparency):

background-color: rgba(var(–primary-rgb), 0.5)



26
27
28
29
# File 'app/helpers/decidim/organization_helper.rb', line 26

def organization_colors
  css = current_organization.colors.each.map { |k, v| "--#{k}: #{v};--#{k}-rgb: #{v[1..2].hex} #{v[3..4].hex} #{v[5..6].hex};" }.join
  render partial: "layouts/decidim/organization_colors", locals: { css: }
end

#organization_description_labelObject



31
32
33
34
35
36
37
# File 'app/helpers/decidim/organization_helper.rb', line 31

def organization_description_label
  @organization_description_label ||= if empty_organization_description?
                                        t("decidim.pages.home.footer_sub_hero.footer_sub_hero_body_html")
                                      else
                                        decidim_sanitize_admin(translated_attribute(current_organization.description))
                                      end
end

#organization_name(organization = current_organization) ⇒ Object



39
40
41
# File 'app/helpers/decidim/organization_helper.rb', line 39

def organization_name(organization = current_organization)
  translated_attribute(organization.name, organization)
end