public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
Introduce ActionView::InlineTemplate class
lifo (author)
Sat Apr 19 08:16:32 -0700 2008
commit  534c6b2444970d59aea654aa3c6aeb41c206d14d
tree    7b5c02b104e3d4cb90ff77c4dfdf88010451c28e
parent  69a5c1df8293fc8de2cec0fc9fa18181cb9ad469
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Introduce ActionView::InlineTemplate class. [Pratik]
0
+
0
 * Automatically parse posted JSON content for Mime::JSON requests. [rick]
0
 
0
   POST /posts
...
870
871
872
873
 
874
875
876
...
870
871
872
 
873
874
875
876
0
@@ -870,7 +870,7 @@
0
 
0
           elsif inline = options[:inline]
0
             add_variables_to_assigns
0
- tmpl = ActionView::Template.new(@template, options[:inline], false, options[:locals], true, options[:type])
0
+ tmpl = ActionView::InlineTemplate.new(@template, options[:inline], options[:locals], options[:type])
0
             render_for_text(@template.render_template(tmpl), options[:status])
0
 
0
           elsif action_name = options[:action]
...
30
31
32
 
33
34
35
...
30
31
32
33
34
35
36
0
@@ -30,6 +30,7 @@
0
 require 'action_view/template_finder'
0
 require 'action_view/template'
0
 require 'action_view/partial_template'
0
+require 'action_view/inline_template'
0
 
0
 require 'action_view/base'
0
 require 'action_view/partials'
...
279
280
281
282
 
283
284
285
...
279
280
281
 
282
283
284
285
0
@@ -279,7 +279,7 @@
0
         elsif options[:partial]
0
           render_partial(options[:partial], ActionView::Base::ObjectWrapper.new(options[:object]), options[:locals])
0
         elsif options[:inline]
0
- template = Template.new(self, options[:inline], false, options[:locals], true, options[:type])
0
+ template = InlineTemplate.new(self, options[:inline], options[:locals], options[:type])
0
           render_template(template)
0
         end
0
       end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0
@@ -1 +1,21 @@
0
+module ActionView #:nodoc:
0
+ class InlineTemplate < Template #:nodoc:
0
+
0
+ def initialize(view, source, locals = {}, type = nil)
0
+ @view = view
0
+ @finder = @view.finder
0
+
0
+ @source = source
0
+ @extension = type
0
+ @locals = locals || {}
0
+
0
+ @handler = self.class.handler_class_for_extension(@extension).new(@view)
0
+ end
0
+
0
+ def method_key
0
+ @source
0
+ end
0
+
0
+ end
0
+end
...
2
3
4
5
 
6
7
 
8
9
10
11
12
13
14
15
16
17
18
19
20
 
 
 
 
 
 
21
22
23
...
32
33
34
35
 
36
37
38
...
2
3
4
 
5
6
 
7
8
9
10
 
 
 
 
 
 
 
 
 
 
11
12
13
14
15
16
17
18
19
...
28
29
30
 
31
32
33
34
0
@@ -2,22 +2,18 @@
0
   class Template #:nodoc:
0
 
0
     attr_accessor :locals
0
- attr_reader :handler, :path, :source, :extension, :filename, :path_without_extension, :method
0
+ attr_reader :handler, :path, :, :extension, :filename, :path_without_extension, :method
0
 
0
- def initialize(view, path_or_source, use_full_path, locals = {}, inline = false, inline_type = nil)
0
+ def initialize(view, path, use_full_path, locals = {})
0
       @view = view
0
       @finder = @view.finder
0
 
0
- unless inline
0
- # Clear the forward slash at the beginning if exists
0
- @path = use_full_path ? path_or_source.sub(/^\//, '') : path_or_source
0
- @view.first_render ||= @path
0
- @source = nil # Don't read the source until we know that it is required
0
- set_extension_and_file_name(use_full_path)
0
- else
0
- @source = path_or_source
0
- @extension = inline_type
0
- end
0
+ # Clear the forward slash at the beginning if exists
0
+ @path = use_full_path ? path.sub(/^\//, '') : path
0
+ @view.first_render ||= @path
0
+ @source = nil # Don't read the source until we know that it is required
0
+ set_extension_and_file_name(use_full_path)
0
+
0
       @locals = locals || {}
0
       @handler = self.class.handler_class_for_extension(@extension).new(@view)
0
     end
0
@@ -32,7 +28,7 @@
0
     end
0
 
0
     def method_key
0
- @method_key ||= (@filename || @source)
0
+ @filename
0
     end
0
 
0
     def base_path_for_exception
...
20
21
22
23
 
24
25
26
...
29
30
31
32
 
33
34
35
...
38
39
40
41
 
42
43
44
...
20
21
22
 
23
24
25
26
...
29
30
31
 
32
33
34
35
...
38
39
40
 
41
42
43
44
0
@@ -20,7 +20,7 @@
0
   end
0
 
0
   def test_custom_render
0
- template = ActionView::Template.new(@view, "hello <%= one %>", false, { :one => "two" }, true, "foo")
0
+ template = ActionView::InlineTemplate.new(@view, "hello <%= one %>", { :one => "two" }, "foo")
0
 
0
     result = @view.render_template(template)
0
     assert_equal(
0
@@ -29,7 +29,7 @@
0
   end
0
 
0
   def test_custom_render2
0
- template = ActionView::Template.new(@view, "hello <%= one %>", false, { :one => "two" }, true, "foo2")
0
+ template = ActionView::InlineTemplate.new(@view, "hello <%= one %>", { :one => "two" }, "foo2")
0
     result = @view.render_template(template)
0
     assert_equal(
0
       [ "hello <%= one %>", { :one => "two" }, @view ],
0
@@ -38,7 +38,7 @@
0
 
0
   def test_unhandled_extension
0
     # uses the ERb handler by default if the extension isn't recognized
0
- template = ActionView::Template.new(@view, "hello <%= one %>", false, { :one => "two" }, true, "bar")
0
+ template = ActionView::InlineTemplate.new(@view, "hello <%= one %>", { :one => "two" }, "bar")
0
     result = @view.render_template(template)
0
     assert_equal "hello two", result
0
   end

Comments

    No one has commented yet.