Module: MetadataPresenter::ApplicationHelper

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

Instance Method Summary collapse

Instance Method Details

#a(component_key) ⇒ Object Also known as: answer

Display user answers on the view When the user doesn’t answered yet the component will be blank or with data otherwise, so doing the if in every output is not pratical.

The below example search for ‘first_name’ in the user data instance variable as long your load_user_data in the controller sets the variable.

Examples:

<%= a('first_name') %>


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

def a(component_key)
  if @user_data.present?
    @user_data[component_key]
  end
end

#to_markdown(text) ⇒ Object



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

def to_markdown(text)
  (Kramdown::Document.new(text).to_html).html_safe
end