mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Hints are assumed html_safe
This commit is contained in:
parent
5f42f0fb6a
commit
ccdcde855b
2 changed files with 17 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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 => '<b>Bold</b> 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 => '<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
|
||||
|
||||
|
|
Loading…
Reference in a new issue