Module: MetadataPresenter::ApplicationHelper

Defined in:
app/helpers/metadata_presenter/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#default_item_title(component_type) ⇒ Object



29
30
31
32
33
# File 'app/helpers/metadata_presenter/application_helper.rb', line 29

def default_item_title(component_type)
  return unless %w[checkboxes radios].include?(component_type)

  MetadataPresenter::DefaultMetadata["component.#{component_type}"]['items']&.first&.[]('label')
end

#default_page_title(type) ⇒ Object



35
36
37
# File 'app/helpers/metadata_presenter/application_helper.rb', line 35

def default_page_title(type)
  MetadataPresenter::DefaultMetadata[type.to_s]&.[]('heading')
end

#default_text(property) ⇒ Object



20
21
22
# File 'app/helpers/metadata_presenter/application_helper.rb', line 20

def default_text(property)
  MetadataPresenter::DefaultText[property]
end

#default_title(component_type) ⇒ Object



24
25
26
27
# File 'app/helpers/metadata_presenter/application_helper.rb', line 24

def default_title(component_type)
  MetadataPresenter::DefaultMetadata["component.#{component_type}"]&.[]('label') ||
    MetadataPresenter::DefaultMetadata["component.#{component_type}"]&.[]('legend')
end

#main_title(component:, tag: :h1, classes: 'govuk-heading-xl') ⇒ Object



5
6
7
8
9
# File 'app/helpers/metadata_presenter/application_helper.rb', line 5

def main_title(component:, tag: :h1, classes: 'govuk-heading-xl')
  (tag, class: classes) do
    component.humanised_title
  end
end

#to_html(text) ⇒ Object

Renders html given markdown.

Examples:

<%=to_html '# Some markdown' %>


16
17
18
# File 'app/helpers/metadata_presenter/application_helper.rb', line 16

def to_html(text)
  Govspeak::Document.new(text).to_html.html_safe
end