class Para::Inputs::I18nInput

Public Instance Methods

input(wrapper_options = nil) click to toggle source
# File lib/para/i18n/i18n_input.rb, line 6
def input(wrapper_options = nil)
  model = object.class
  render
end
render() click to toggle source
# File lib/para/i18n/i18n_input.rb, line 11
def render
  content_tag(:div, class: 'row') do
    content_tag(:div, class: 'col-md-6') do
      ::I18n.with_locale(::I18n.default_locale) do
        original_content
      end
    end +
    content_tag(:div, class: 'col-md-6') do
      ::I18n.with_locale(locale) do
        @builder.input_field(attribute_name, input_options)
      end
    end
  end
end

Private Instance Methods

input_options() click to toggle source
# File lib/para/i18n/i18n_input.rb, line 46
def input_options
  @input_options ||= (options[:input_html] || {}).tap do |hash|
    hash[:class] ||= ''
    hash[:class] += ' form-control'
  end
end
locale() click to toggle source
# File lib/para/i18n/i18n_input.rb, line 28
def locale
  locale = options.fetch(:locale, @builder.target_locale)
  return locale if locale.present?

  raise 'No target locale for the current i18n input. Please provide a `:locale`' \
        'option to the :i18n input or the `para_translations_form_for` method'
end
original_content() click to toggle source
# File lib/para/i18n/i18n_input.rb, line 36
def original_content
  value = template.value_for(object, attribute_name)
  value = value.html_safe if original_options[:html_safe] && value
  value
end
original_options() click to toggle source
# File lib/para/i18n/i18n_input.rb, line 42
def original_options
  @original_options ||= options[:original_html] || {}
end