1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00
heartcombo--simple_form/lib/simple_form/components/hints.rb
Lauro Caetano 63fb9a2773 Change the translation mechanism to use
`ActionView::Helpers::TranslationHelper`.

It has some advantages over only using `I18n.t`, such as the safe
translation if the key has the suffix `_html`.
2014-04-04 14:51:21 -03:00

23 lines
517 B
Ruby

module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups.
module Hints
def hint(wrapper_options = nil)
@hint ||= begin
hint = options[:hint]
if hint.is_a?(String)
html_escape(hint)
else
content = translate_from_namespace(:hints)
content.html_safe if content
end
end
end
def has_hint?
options[:hint] != false && hint.present?
end
end
end
end