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
|
def hint
|
||||||
@hint ||= begin
|
@hint ||= begin
|
||||||
hint = options[:hint]
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,12 @@ class HintTest < ActionView::TestCase
|
||||||
assert_select 'span#hint.hint.yay'
|
assert_select 'span#hint.hint.yay'
|
||||||
end
|
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
|
# Without attribute name
|
||||||
|
|
||||||
test 'hint without attribute name' do
|
test 'hint without attribute name' do
|
||||||
|
@ -105,6 +111,16 @@ class HintTest < ActionView::TestCase
|
||||||
end
|
end
|
||||||
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
|
# No object
|
||||||
|
|
||||||
test 'hint should generate properly when object is not present' do
|
test 'hint should generate properly when object is not present' do
|
||||||
|
|
Loading…
Reference in a new issue