Module: Decidim::Design::ApplicationHelper
- Defined in:
- decidim-design/app/helpers/decidim/design/application_helper.rb
Constant Summary collapse
- RELEASE_ID =
For the moment keep this as a constant and later decide where to move this
"develop"
Instance Method Summary collapse
- #cell_snippet_locals(cell, args) ⇒ Object
- #render_cell(cell) ⇒ Object
- #render_cell_snippet(content) ⇒ Object
- #render_content(content) ⇒ Object
- #render_row(row) ⇒ Object
- #section_text(section) ⇒ Object
- #section_title(section) ⇒ Object
Instance Method Details
#cell_snippet_locals(cell, args) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'decidim-design/app/helpers/decidim/design/application_helper.rb', line 41 def cell_snippet_locals(cell, args) path = args.delete(:path) || File.join("decidim-core/app/cells/", cell) { text: path, url: "https://github.com/decidim/decidim/blob/#{RELEASE_ID}/#{path}_cell.rb", cell:, args: } end |
#render_cell(cell) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'decidim-design/app/helpers/decidim/design/application_helper.rb', line 61 def render_cell(cell) content_tag(:td) do if cell.is_a?(Hash) send(cell[:method], *cell[:args]).to_s else cell end end end |
#render_cell_snippet(content) ⇒ Object
35 36 37 38 39 |
# File 'decidim-design/app/helpers/decidim/design/application_helper.rb', line 35 def render_cell_snippet(content) return "" if content[:cell_snippet].blank? render partial: "decidim/design/shared/cell_snippet", locals: cell_snippet_locals(content[:cell_snippet][:cell], content[:cell_snippet][:args]) end |
#render_content(content) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'decidim-design/app/helpers/decidim/design/application_helper.rb', line 18 def render_content(content) case content[:type] when :text html = "" content[:values].each do |value| html += content_tag(:p, value, class: content[:class]) end html.html_safe when :table render partial: "decidim/design/shared/table", locals: content.slice(:items).merge(content[:options] || {}) when :partial render partial: content[:template], locals: content[:locals] else content[:values].to_s.html_safe end end |
#render_row(row) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'decidim-design/app/helpers/decidim/design/application_helper.rb', line 51 def render_row(row) if row.is_a?(Array) html = "" row.each do |cell| html += render_cell(cell) end html.html_safe end end |
#section_text(section) ⇒ Object
14 15 16 |
# File 'decidim-design/app/helpers/decidim/design/application_helper.rb', line 14 def section_text(section) section[:title] || section[:id].titleize end |
#section_title(section) ⇒ Object
10 11 12 |
# File 'decidim-design/app/helpers/decidim/design/application_helper.rb', line 10 def section_title(section) content_tag(:h2, section_text(section), class: "design__heading__3xl") end |