Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
db17046b
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,发现更多精彩内容 >>
提交
db17046b
编写于
9月 10, 2012
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7594 from guilleiguaran/rb-template-handler
Add .rb template handler
上级
b2063f2a
ab7ae689
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
14 addition
and
0 deletion
+14
-0
actionpack/CHANGELOG.md
actionpack/CHANGELOG.md
+2
-0
actionpack/lib/action_view/template/handlers.rb
actionpack/lib/action_view/template/handlers.rb
+1
-0
actionpack/test/fixtures/ruby_template.rb
actionpack/test/fixtures/ruby_template.rb
+3
-0
actionpack/test/template/render_test.rb
actionpack/test/template/render_test.rb
+8
-0
未找到文件。
actionpack/CHANGELOG.md
浏览文件 @
db17046b
## Rails 4.0.0 (unreleased) ##
*
Add .rb template handler, this handler simply allows arbitrary Ruby code as a template.
*Guillermo Iguaran*
*
Add
`separator`
option for
`ActionView::Helpers::TextHelper#excerpt`
:
excerpt('This is a very beautiful morning', 'very', :separator => ' ', :radius => 1)
...
...
actionpack/lib/action_view/template/handlers.rb
浏览文件 @
db17046b
...
...
@@ -10,6 +10,7 @@ def self.extended(base)
base
.
register_default_template_handler
:erb
,
ERB
.
new
base
.
register_template_handler
:builder
,
Builder
.
new
base
.
register_template_handler
:raw
,
Raw
.
new
base
.
register_template_handler
:rb
,
:source
.
to_proc
end
@@template_handlers
=
{}
...
...
actionpack/test/fixtures/ruby_template.rb
0 → 100644
浏览文件 @
db17046b
body
=
""
body
<<
[
"Hello"
,
"from"
,
"Ruby"
,
"code"
].
join
(
" "
)
body
actionpack/test/template/render_test.rb
浏览文件 @
db17046b
...
...
@@ -97,6 +97,14 @@ def test_render_raw_template_with_quotes
assert_equal
%q;Here are some characters: !@#$%^&*()-="'}{`;
+
"
\n
"
,
@view
.
render
(
:template
=>
"plain_text_with_characters"
)
end
def
test_render_rb_template_with_handlers
assert_equal
"Hello from Ruby code"
,
@view
.
render
(
:template
=>
"ruby_template"
)
end
def
test_render_rb_template_inline
assert_equal
'4'
,
@view
.
render
(
:inline
=>
"(2**2).to_s"
,
:type
=>
:rb
)
end
def
test_render_file_with_localization_on_context_level
old_locale
,
@view
.
locale
=
@view
.
locale
,
:da
assert_equal
"Hey verden"
,
@view
.
render
(
:file
=>
"test/hello_world"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录