Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
b3778c57
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b3778c57
编写于
2月 21, 2019
作者:
A
Abhay Nikam
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allows rich_text_area_tag to add I18n translated placeholder text if placeholder option set to true
上级
3b6602aa
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
2 deletion
+52
-2
actiontext/app/helpers/action_text/tag_helper.rb
actiontext/app/helpers/action_text/tag_helper.rb
+4
-0
actiontext/test/template/form_helper_test.rb
actiontext/test/template/form_helper_test.rb
+48
-2
未找到文件。
actiontext/app/helpers/action_text/tag_helper.rb
浏览文件 @
b3778c57
# frozen_string_literal: true
require
"action_view/helpers/tags/placeholderable"
module
ActionText
module
TagHelper
cattr_accessor
(
:id
,
instance_accessor:
false
)
{
0
}
...
...
@@ -35,6 +37,8 @@ def rich_text_area_tag(name, value = nil, options = {})
module
ActionView::Helpers
class
Tags::ActionText
<
Tags
::
Base
include
Tags
::
Placeholderable
delegate
:dom_id
,
to:
ActionView
::
RecordIdentifier
def
render
...
...
actiontext/test/template/form_helper_test.rb
浏览文件 @
b3778c57
...
...
@@ -5,6 +5,26 @@
class
ActionText::FormHelperTest
<
ActionView
::
TestCase
tests
ActionText
::
TagHelper
def
form_with
(
*
)
@output_buffer
=
super
end
teardown
do
I18n
.
backend
.
reload!
end
setup
do
I18n
.
backend
.
store_translations
(
"placeholder"
,
activerecord:
{
attributes:
{
message:
{
title:
"Story title"
}
}
}
)
end
test
"form with rich text area"
do
form_with
model:
Message
.
new
,
scope: :message
do
|
form
|
form
.
rich_text_area
:content
...
...
@@ -61,7 +81,33 @@ class ActionText::FormHelperTest < ActionView::TestCase
output_buffer
end
def
form_with
(
*
)
@output_buffer
=
super
test
"form with rich text area having placeholder without locale"
do
form_with
model:
Message
.
new
,
scope: :message
do
|
form
|
form
.
rich_text_area
:content
,
placeholder:
true
end
assert_dom_equal
\
'<form action="/messages" accept-charset="UTF-8" data-remote="true" method="post">'
\
'<input type="hidden" name="message[content]" id="message_content_trix_input_message" />'
\
'<trix-editor placeholder="Content" id="message_content" input="message_content_trix_input_message" class="trix-content" data-direct-upload-url="http://test.host/rails/active_storage/direct_uploads" data-blob-url-template="http://test.host/rails/active_storage/blobs/:signed_id/:filename">'
\
"</trix-editor>"
\
"</form>"
,
output_buffer
end
test
"form with rich text area having placeholder with locale"
do
I18n
.
with_locale
:placeholder
do
form_with
model:
Message
.
new
,
scope: :message
do
|
form
|
form
.
rich_text_area
:title
,
placeholder:
true
end
end
assert_dom_equal
\
'<form action="/messages" accept-charset="UTF-8" data-remote="true" method="post">'
\
'<input type="hidden" name="message[title]" id="message_title_trix_input_message" />'
\
'<trix-editor placeholder="Story title" id="message_title" input="message_title_trix_input_message" class="trix-content" data-direct-upload-url="http://test.host/rails/active_storage/direct_uploads" data-blob-url-template="http://test.host/rails/active_storage/blobs/:signed_id/:filename">'
\
"</trix-editor>"
\
"</form>"
,
output_buffer
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录