Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #506 from findrails/master

Update to treat hints as html_safe

Closes #505
  • Loading branch information...
commit b347a34b4103af730c4d2645f5bb5a0d7ceaf24b 2 parents 5f42f0f + 739f4da
@rafaelfranca rafaelfranca authored
View
3  lib/simple_form/components/hints.rb
@@ -5,7 +5,8 @@ module Hints
def hint
@hint ||= begin
hint = options[:hint]
- hint.is_a?(String) ? hint : translate(:hints)
+ hint_content = hint.is_a?(String) ? hint : translate(:hints)
+ hint_content.html_safe if hint_content
end
end
View
16 test/form_builder/hint_test.rb
@@ -41,6 +41,12 @@ def with_hint_for(object, *args)
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 => '<b>Bold</b> and not...'
+ assert_select 'span.hint', 'Bold and not...'
+ end
+
# Without attribute name
@@ -104,6 +110,16 @@ def with_hint_for(object, *args)
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 => '<b>This is bold</b> 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
Please sign in to comment.
Something went wrong with that request. Please try again.