Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
39ba2da8
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,发现更多精彩内容 >>
提交
39ba2da8
编写于
7月 05, 2008
作者:
J
Joshua Peek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Moved complied method name logic into Renderable
上级
1dcc5912
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
23 deletion
+24
-23
actionpack/lib/action_view/inline_template.rb
actionpack/lib/action_view/inline_template.rb
+10
-0
actionpack/lib/action_view/renderable.rb
actionpack/lib/action_view/renderable.rb
+4
-0
actionpack/lib/action_view/template.rb
actionpack/lib/action_view/template.rb
+8
-1
actionpack/lib/action_view/template_handlers/compilable.rb
actionpack/lib/action_view/template_handlers/compilable.rb
+2
-22
未找到文件。
actionpack/lib/action_view/inline_template.rb
浏览文件 @
39ba2da8
...
...
@@ -2,6 +2,10 @@ module ActionView #:nodoc:
class
InlineTemplate
#:nodoc:
include
Renderable
# Count the number of inline templates
cattr_accessor
:inline_template_count
@@inline_template_count
=
0
def
initialize
(
view
,
source
,
locals
=
{},
type
=
nil
)
@view
=
view
...
...
@@ -12,5 +16,11 @@ def initialize(view, source, locals = {}, type = nil)
@method_key
=
@source
@handler
=
Template
.
handler_class_for_extension
(
@extension
).
new
(
@view
)
end
private
# FIXME: Modifying this shared variable may not thread safe
def
method_name_path_segment
"inline_
#{
@@inline_template_count
+=
1
}
"
end
end
end
actionpack/lib/action_view/renderable.rb
浏览文件 @
39ba2da8
...
...
@@ -11,6 +11,10 @@ def render
@handler
.
render
(
self
)
end
def
method_name
[
'_run'
,
@extension
,
method_name_path_segment
].
compact
.
join
(
'_'
).
to_sym
end
private
def
prepare!
unless
@prepared
...
...
actionpack/lib/action_view/template.rb
浏览文件 @
39ba2da8
...
...
@@ -37,7 +37,7 @@ def render_template
end
def
source
@source
||=
File
.
read
(
self
.
filename
)
@source
||=
File
.
read
(
@
filename
)
end
def
base_path_for_exception
...
...
@@ -71,5 +71,12 @@ def raise_missing_template_exception
template_type
=
(
@original_path
=~
/layouts/i
)
?
'layout'
:
'template'
raise
MissingTemplate
,
"Missing
#{
template_type
}
#{
full_template_path
}
in view path
#{
display_paths
}
"
end
def
method_name_path_segment
s
=
File
.
expand_path
(
@filename
)
s
.
sub!
(
/^
#{
Regexp
.
escape
(
File
.
expand_path
(
RAILS_ROOT
))
}
/
,
''
)
if
defined?
(
RAILS_ROOT
)
s
.
gsub!
(
/([^a-zA-Z0-9_])/
)
{
$1
.
ord
}
s
end
end
end
actionpack/lib/action_view/template_handlers/compilable.rb
浏览文件 @
39ba2da8
module
ActionView
module
TemplateHandlers
module
Compilable
def
self
.
included
(
base
)
base
.
extend
ClassMethod
...
...
@@ -12,10 +11,6 @@ def self.included(base)
# Map method names to the names passed in local assigns so far
base
.
cattr_accessor
:template_args
base
.
template_args
=
{}
# Count the number of inline templates
base
.
cattr_accessor
:inline_template_count
base
.
inline_template_count
=
0
end
module
ClassMethod
...
...
@@ -24,7 +19,7 @@ def compilable?
true
end
end
def
render
(
template
)
@view
.
send
:execute
,
template
end
...
...
@@ -75,22 +70,7 @@ def compile_template?(template)
end
def
assign_method_name
(
template
)
@view
.
method_names
[
template
.
method_key
]
||=
compiled_method_name
(
template
)
end
def
compiled_method_name
(
template
)
[
'_run'
,
self
.
class
.
to_s
.
demodulize
.
underscore
,
compiled_method_name_file_path_segment
(
template
.
filename
)].
compact
.
join
(
'_'
).
to_sym
end
def
compiled_method_name_file_path_segment
(
file_name
)
if
file_name
s
=
File
.
expand_path
(
file_name
)
s
.
sub!
(
/^
#{
Regexp
.
escape
(
File
.
expand_path
(
RAILS_ROOT
))
}
/
,
''
)
if
defined?
(
RAILS_ROOT
)
s
.
gsub!
(
/([^a-zA-Z0-9_])/
)
{
$1
.
ord
}
s
else
(
self
.
inline_template_count
+=
1
).
to_s
end
@view
.
method_names
[
template
.
method_key
]
||=
template
.
method_name
end
# Method to create the source code for a given template.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录