diff --git a/lib/simple_form/components/hints.rb b/lib/simple_form/components/hints.rb
index e1343d64..9f11e412 100644
--- a/lib/simple_form/components/hints.rb
+++ b/lib/simple_form/components/hints.rb
@@ -5,7 +5,7 @@ module SimpleForm
def hint
@hint ||= begin
hint = options[:hint]
- hint.is_a?(String) ? hint : translate(:hints)
+ hint.is_a?(String) ? hint.html_safe : (translate(:hints).html_safe if translate(:hints))
end
end
diff --git a/test/form_builder/hint_test.rb b/test/form_builder/hint_test.rb
index 32060934..a6f0798c 100644
--- a/test/form_builder/hint_test.rb
+++ b/test/form_builder/hint_test.rb
@@ -41,6 +41,12 @@ class HintTest < ActionView::TestCase
with_hint_for @user, :name, :hint => 'Yay!', :id => 'hint', :class => 'yay'
assert_select 'span#hint.hint.yay'
end
+
+ test 'hint should be output as html_safe' do
+ with_hint_for @user, :name, :hint => 'Bold and not...'
+ assert_select 'span.hint', 'Bold and not...'
+ end
+
# Without attribute name
@@ -104,6 +110,16 @@ class HintTest < ActionView::TestCase
assert_select 'span.hint', /My company!/
end
end
+
+ test 'hint should output translations as html_safe' do
+ store_translations(:en, :simple_form => { :hints => { :user => {
+ :edit => { :name => 'This is bold and this is not...' }
+ } } }) do
+ with_hint_for @user, :name
+ assert_select 'span.hint', 'This is bold and this is not...'
+ end
+ end
+
# No object