public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
Check whether blocks are called from erb using a special __in_erb_template 
variable visible in block binding.
jeremy (author)
Thu Jun 19 22:03:27 -0700 2008
commit  72f93b581f1d1a7496ccebbd90578714c171c5a5
tree    0e89550d0297bba6a87c8eae507c7388d62c92e8
parent  c440c9b199d7474e356472616ef03f9c7e17c405
...
31
32
33
34
 
 
35
 
 
36
37
 
38
39
40
...
117
118
119
 
120
121
122
...
31
32
33
 
34
35
36
37
38
39
 
40
41
42
43
...
120
121
122
123
124
125
126
0
@@ -31,10 +31,13 @@ module ActionView
0
       # </body></html>
0
       #
0
       def capture(*args, &block)
0
- if output_buffer
0
+ # Return captured buffer in erb.
0
+ if block_called_from_erb?(block)
0
           with_output_buffer { block.call(*args) }
0
+
0
+ # Return block result otherwise, but protect buffer also.
0
         else
0
- block.call(*args)
0
+ with_output_buffer { return block.call(*args) }
0
         end
0
       end
0
 
0
@@ -117,6 +120,7 @@ module ActionView
0
         ivar = "@content_for_#{name}"
0
         content = capture(&block) if block_given?
0
         instance_variable_set(ivar, "#{instance_variable_get(ivar)}#{content}")
0
+ nil
0
       end
0
 
0
       private
...
6
7
8
9
 
10
11
12
...
20
21
22
23
 
24
25
26
 
27
28
29
 
30
31
 
32
33
34
...
88
89
90
91
 
92
93
94
...
146
147
148
149
 
150
151
152
153
154
155
 
156
157
158
...
160
161
162
163
 
164
165
166
...
181
182
183
184
 
185
186
187
...
286
287
288
289
 
290
291
292
...
313
314
315
316
 
317
318
319
320
321
322
323
 
324
325
326
...
335
336
337
338
 
339
340
341
...
346
347
348
349
 
350
351
352
...
358
359
360
361
 
362
363
364
365
366
 
367
368
369
 
370
371
372
...
412
413
414
415
 
416
417
418
...
420
421
422
423
 
424
425
426
...
434
435
436
437
 
438
439
440
441
442
 
443
444
445
...
6
7
8
 
9
10
11
12
...
20
21
22
 
23
24
25
 
26
27
28
 
29
30
 
31
32
33
34
...
88
89
90
 
91
92
93
94
...
146
147
148
 
149
150
151
152
153
154
 
155
156
157
158
...
160
161
162
 
163
164
165
166
...
181
182
183
 
184
185
186
187
...
286
287
288
 
289
290
291
292
...
313
314
315
 
316
317
318
319
320
321
322
 
323
324
325
326
...
335
336
337
 
338
339
340
341
...
346
347
348
 
349
350
351
352
...
358
359
360
 
361
362
363
364
365
 
366
367
368
 
369
370
371
372
...
412
413
414
 
415
416
417
418
...
420
421
422
 
423
424
425
426
...
434
435
436
 
437
438
439
440
441
 
442
443
444
445
0
@@ -6,7 +6,7 @@ module ActionView
0
     # Provides a number of methods for creating form tags that doesn't rely on an Active Record object assigned to the template like
0
     # FormHelper does. Instead, you provide the names and values manually.
0
     #
0
- # NOTE: The HTML options <tt>disabled</tt>, <tt>readonly</tt>, and <tt>multiple</tt> can all be treated as booleans. So specifying
0
+ # NOTE: The HTML options <tt>disabled</tt>, <tt>readonly</tt>, and <tt>multiple</tt> can all be treated as booleans. So specifying
0
     # <tt>:disabled => true</tt> will give <tt>disabled="disabled"</tt>.
0
     module FormTagHelper
0
       # Starts a form tag that points the action to an url configured with <tt>url_for_options</tt> just like
0
@@ -20,15 +20,15 @@ module ActionView
0
       # * A list of parameters to feed to the URL the form will be posted to.
0
       #
0
       # ==== Examples
0
- # form_tag('/posts')
0
+ # form_tag('/posts')
0
       # # => <form action="/posts" method="post">
0
       #
0
- # form_tag('/posts/1', :method => :put)
0
+ # form_tag('/posts/1', :method => :put)
0
       # # => <form action="/posts/1" method="put">
0
       #
0
- # form_tag('/upload', :multipart => true)
0
+ # form_tag('/upload', :multipart => true)
0
       # # => <form action="/upload" method="post" enctype="multipart/form-data">
0
- #
0
+ #
0
       # <% form_tag '/posts' do -%>
0
       # <div><%= submit_tag 'Save' %></div>
0
       # <% end -%>
0
@@ -88,7 +88,7 @@ module ActionView
0
       # * <tt>:size</tt> - The number of visible characters that will fit in the input.
0
       # * <tt>:maxlength</tt> - The maximum number of characters that the browser will allow the user to enter.
0
       # * Any other key creates standard HTML attributes for the tag.
0
- #
0
+ #
0
       # ==== Examples
0
       # text_field_tag 'name'
0
       # # => <input id="name" name="name" type="text" />
0
@@ -146,13 +146,13 @@ module ActionView
0
       # # => <input id="token" name="token" type="hidden" value="VUBJKB23UIVI1UU1VOBVI@" />
0
       #
0
       # hidden_field_tag 'collected_input', '', :onchange => "alert('Input collected!')"
0
- # # => <input id="collected_input" name="collected_input" onchange="alert('Input collected!')"
0
+ # # => <input id="collected_input" name="collected_input" onchange="alert('Input collected!')"
0
       # # type="hidden" value="" />
0
       def hidden_field_tag(name, value = nil, options = {})
0
         text_field_tag(name, value, options.stringify_keys.update("type" => "hidden"))
0
       end
0
 
0
- # Creates a file upload field. If you are using file uploads then you will also need
0
+ # Creates a file upload field. If you are using file uploads then you will also need
0
       # to set the multipart option for the form tag:
0
       #
0
       # <%= form_tag { :action => "post" }, { :multipart => true } %>
0
@@ -160,7 +160,7 @@ module ActionView
0
       # <%= submit_tag %>
0
       # <%= end_form_tag %>
0
       #
0
- # The specified URL will then be passed a File object containing the selected file, or if the field
0
+ # The specified URL will then be passed a File object containing the selected file, or if the field
0
       # was left blank, a StringIO object.
0
       #
0
       # ==== Options
0
@@ -181,7 +181,7 @@ module ActionView
0
       # # => <input id="resume" name="resume" type="file" value="~/resume.doc" />
0
       #
0
       # file_field_tag 'user_pic', :accept => 'image/png,image/gif,image/jpeg'
0
- # # => <input accept="image/png,image/gif,image/jpeg" id="user_pic" name="user_pic" type="file" />
0
+ # # => <input accept="image/png,image/gif,image/jpeg" id="user_pic" name="user_pic" type="file" />
0
       #
0
       # file_field_tag 'file', :accept => 'text/html', :class => 'upload', :value => 'index.html'
0
       # # => <input accept="text/html" class="upload" id="file" name="file" type="file" value="index.html" />
0
@@ -286,7 +286,7 @@ module ActionView
0
         tag :input, html_options
0
       end
0
 
0
- # Creates a radio button; use groups of radio buttons named the same to allow users to
0
+ # Creates a radio button; use groups of radio buttons named the same to allow users to
0
       # select from a group of options.
0
       #
0
       # ==== Options
0
@@ -313,14 +313,14 @@ module ActionView
0
         tag :input, html_options
0
       end
0
 
0
- # Creates a submit button with the text <tt>value</tt> as the caption.
0
+ # Creates a submit button with the text <tt>value</tt> as the caption.
0
       #
0
       # ==== Options
0
       # * <tt>:confirm => 'question?'</tt> - This will add a JavaScript confirm
0
       # prompt with the question specified. If the user accepts, the form is
0
       # processed normally, otherwise no action is taken.
0
       # * <tt>:disabled</tt> - If true, the user will not be able to use this input.
0
- # * <tt>:disable_with</tt> - Value of this parameter will be used as the value for a disabled version
0
+ # * <tt>:disable_with</tt> - Value of this parameter will be used as the value for a disabled version
0
       # of the submit button when the form is submitted.
0
       # * Any other key creates standard HTML options for the tag.
0
       #
0
@@ -335,7 +335,7 @@ module ActionView
0
       # # => <input disabled="disabled" name="commit" type="submit" value="Save edits" />
0
       #
0
       # submit_tag "Complete sale", :disable_with => "Please wait..."
0
- # # => <input name="commit" onclick="this.disabled=true;this.value='Please wait...';this.form.submit();"
0
+ # # => <input name="commit" onclick="this.disabled=true;this.value='Please wait...';this.form.submit();"
0
       # # type="submit" value="Complete sale" />
0
       #
0
       # submit_tag nil, :class => "form_submit"
0
@@ -346,7 +346,7 @@ module ActionView
0
       # # name="commit" type="submit" value="Edit" />
0
       def submit_tag(value = "Save changes", options = {})
0
         options.stringify_keys!
0
-
0
+
0
         if disable_with = options.delete("disable_with")
0
           options["onclick"] = [
0
             "this.setAttribute('originalValue', this.value)",
0
@@ -358,15 +358,15 @@ module ActionView
0
             "return result;",
0
           ].join(";")
0
         end
0
-
0
+
0
         if confirm = options.delete("confirm")
0
           options["onclick"] ||= ''
0
           options["onclick"] += "return #{confirm_javascript_function(confirm)};"
0
         end
0
-
0
+
0
         tag :input, { "type" => "submit", "name" => "commit", "value" => value }.update(options.stringify_keys)
0
       end
0
-
0
+
0
       # Displays an image which when clicked will submit the form.
0
       #
0
       # <tt>source</tt> is passed to AssetTagHelper#image_path
0
@@ -412,7 +412,7 @@ module ActionView
0
         concat(content)
0
         concat("</fieldset>")
0
       end
0
-
0
+
0
       private
0
         def html_options_for_form(url_for_options, options, *parameters_for_url)
0
           returning options.stringify_keys do |html_options|
0
@@ -420,7 +420,7 @@ module ActionView
0
             html_options["action"] = url_for(url_for_options, *parameters_for_url)
0
           end
0
         end
0
-
0
+
0
         def extra_tags_for_form(html_options)
0
           case method = html_options.delete("method").to_s
0
             when /^get$/i # must be case-insentive, but can't use downcase as might be nil
0
@@ -434,12 +434,12 @@ module ActionView
0
               content_tag(:div, tag(:input, :type => "hidden", :name => "_method", :value => method) + token_tag, :style => 'margin:0;padding:0')
0
           end
0
         end
0
-
0
+
0
         def form_tag_html(html_options)
0
           extra_tags = extra_tags_for_form(html_options)
0
           tag(:form, html_options, true) + extra_tags
0
         end
0
-
0
+
0
         def form_tag_in_block(html_options, &block)
0
           content = capture(&block)
0
           concat(form_tag_html(html_options))
...
12
13
14
15
16
17
 
 
 
18
19
20
21
22
 
23
24
25
...
30
31
32
33
 
34
35
36
...
43
44
45
46
 
47
48
49
50
51
52
 
53
54
55
...
68
69
70
71
 
 
 
 
 
 
 
72
73
74
...
102
103
104
 
 
 
 
 
 
 
 
 
 
105
106
107
...
12
13
14
 
 
 
15
16
17
18
19
20
21
 
22
23
24
25
...
30
31
32
 
33
34
35
36
...
43
44
45
 
46
47
48
49
50
51
 
52
53
54
55
...
68
69
70
 
71
72
73
74
75
76
77
78
79
80
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
0
@@ -12,14 +12,14 @@ module ActionView
0
       BOOLEAN_ATTRIBUTES = %w(disabled readonly multiple).to_set
0
       BOOLEAN_ATTRIBUTES.merge(BOOLEAN_ATTRIBUTES.map(&:to_sym))
0
 
0
- # Returns an empty HTML tag of type +name+ which by default is XHTML
0
- # compliant. Set +open+ to true to create an open tag compatible
0
- # with HTML 4.0 and below. Add HTML attributes by passing an attributes
0
+ # Returns an empty HTML tag of type +name+ which by default is XHTML
0
+ # compliant. Set +open+ to true to create an open tag compatible
0
+ # with HTML 4.0 and below. Add HTML attributes by passing an attributes
0
       # hash to +options+. Set +escape+ to false to disable attribute value
0
       # escaping.
0
       #
0
       # ==== Options
0
- # The +options+ hash is used with attributes with no value like (<tt>disabled</tt> and
0
+ # The +options+ hash is used with attributes with no value like (<tt>disabled</tt> and
0
       # <tt>readonly</tt>), which you can give a value of true in the +options+ hash. You can use
0
       # symbols or strings for the attribute names.
0
       #
0
@@ -30,7 +30,7 @@ module ActionView
0
       # tag("br", nil, true)
0
       # # => <br>
0
       #
0
- # tag("input", { :type => 'text', :disabled => true })
0
+ # tag("input", { :type => 'text', :disabled => true })
0
       # # => <input type="text" disabled="disabled" />
0
       #
0
       # tag("img", { :src => "open & shut.png" })
0
@@ -43,13 +43,13 @@ module ActionView
0
       end
0
 
0
       # Returns an HTML block tag of type +name+ surrounding the +content+. Add
0
- # HTML attributes by passing an attributes hash to +options+.
0
+ # HTML attributes by passing an attributes hash to +options+.
0
       # Instead of passing the content as an argument, you can also use a block
0
       # in which case, you pass your +options+ as the second parameter.
0
       # Set escape to false to disable attribute value escaping.
0
       #
0
       # ==== Options
0
- # The +options+ hash is used with attributes with no value like (<tt>disabled</tt> and
0
+ # The +options+ hash is used with attributes with no value like (<tt>disabled</tt> and
0
       # <tt>readonly</tt>), which you can give a value of true in the +options+ hash. You can use
0
       # symbols or strings for the attribute names.
0
       #
0
@@ -68,7 +68,13 @@ module ActionView
0
       def content_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block)
0
         if block_given?
0
           options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
0
- concat(content_tag_string(name, capture(&block), options, escape))
0
+ content_tag = content_tag_string(name, capture(&block), options, escape)
0
+
0
+ if block_called_from_erb?(block)
0
+ concat(content_tag)
0
+ else
0
+ content_tag
0
+ end
0
         else
0
           content_tag_string(name, content_or_options_with_block, options, escape)
0
         end
0
@@ -102,6 +108,16 @@ module ActionView
0
       end
0
 
0
       private
0
+ BLOCK_CALLED_FROM_ERB = 'defined? __in_erb_template'
0
+
0
+ # Check whether we're called from an erb template.
0
+ # We'd return a string in any other case, but erb <%= ... %>
0
+ # can't take an <% end %> later on, so we have to use <% ... %>
0
+ # and implicitly concat.
0
+ def block_called_from_erb?(block)
0
+ eval(BLOCK_CALLED_FROM_ERB, block)
0
+ end
0
+
0
         def content_tag_string(name, content, options, escape = true)
0
           tag_options = tag_options(options, escape) if options
0
           "<#{name}#{tag_options}>#{content}</#{name}>"
...
30
31
32
33
34
35
36
37
 
38
39
40
...
30
31
32
 
 
 
 
 
33
34
35
36
0
@@ -30,11 +30,7 @@ module ActionView
0
           ActiveSupport::Deprecation.warn("The binding argument of #concat is no longer needed. Please remove it from your views and helpers.")
0
         end
0
 
0
- if output_buffer && string
0
- output_buffer << string
0
- else
0
- string
0
- end
0
+ output_buffer << string
0
       end
0
 
0
       if RUBY_VERSION < '1.9'
...
106
107
108
109
 
 
 
 
 
 
 
110
111
112
...
106
107
108
 
109
110
111
112
113
114
115
116
117
118
0
@@ -106,7 +106,13 @@ module ActionView
0
           locals_code << "#{key} = local_assigns[:#{key}]\n"
0
         end
0
 
0
- "def #{render_symbol}(local_assigns)\nold_output_buffer = output_buffer;#{locals_code}#{body}\nensure\nself.output_buffer = old_output_buffer\nend"
0
+ <<-end_src
0
+ def #{render_symbol}(local_assigns)
0
+ old_output_buffer = output_buffer;#{locals_code}#{body}
0
+ ensure
0
+ self.output_buffer = old_output_buffer
0
+ end
0
+ end_src
0
       end
0
 
0
       # Return true if the given template was compiled for a superset of the keys in local_assigns
...
48
49
50
51
 
 
52
53
54
...
48
49
50
 
51
52
53
54
55
0
@@ -48,7 +48,8 @@ module ActionView
0
       self.erb_trim_mode = '-'
0
 
0
       def compile(template)
0
- ::ERB.new(template.source, nil, erb_trim_mode, '@output_buffer').src
0
+ src = ::ERB.new(template.source, nil, erb_trim_mode, '@output_buffer').src
0
+ "__in_erb_template=true;#{src}"
0
       end
0
 
0
       def cache_fragment(block, name = {}, options = nil) #:nodoc:
...
1
2
3
4
5
 
...
1
2
3
 
4
5
0
@@ -1,4 +1,4 @@
0
 content_for :title do
0
   'Putting stuff in the title!'
0
 end
0
-xml << "\nGreat stuff!"
0
\ No newline at end of file
0
+xml << "\nGreat stuff!"
...
35
36
37
38
 
39
40
41
42
43
44
45
 
 
46
47
48
49
50
51
52
 
 
53
54
55
...
88
89
90
91
 
92
93
94
95
 
96
97
98
...
103
104
105
106
 
107
108
109
110
111
112
 
113
114
115
...
145
146
147
148
 
149
150
151
152
153
154
 
155
156
157
158
159
160
 
161
162
163
164
165
166
 
167
168
169
170
171
172
 
173
174
175
176
177
178
 
179
180
181
...
226
227
228
229
 
230
231
232
233
234
 
 
235
236
237
...
35
36
37
 
38
39
40
41
42
43
44
 
45
46
47
48
49
50
51
52
 
53
54
55
56
57
...
90
91
92
 
93
94
95
96
 
97
98
99
100
...
105
106
107
 
108
109
110
111
112
113
 
114
115
116
117
...
147
148
149
 
150
151
152
153
154
155
 
156
157
158
159
160
161
 
162
163
164
165
166
167
 
168
169
170
171
172
173
 
174
175
176
177
178
179
 
180
181
182
183
...
228
229
230
 
231
232
233
234
235
 
236
237
238
239
240
0
@@ -35,21 +35,23 @@ class FormTagHelperTest < ActionView::TestCase
0
     expected = %(<form action="http://www.example.com" method="post"><div style='margin:0;padding:0'><input type="hidden" name="_method" value="put" /></div>)
0
     assert_dom_equal expected, actual
0
   end
0
-
0
+
0
   def test_form_tag_with_method_delete
0
     actual = form_tag({}, { :method => :delete })
0
     expected = %(<form action="http://www.example.com" method="post"><div style='margin:0;padding:0'><input type="hidden" name="_method" value="delete" /></div>)
0
     assert_dom_equal expected, actual
0
   end
0
 
0
- def test_form_tag_with_block
0
+ def test_form_tag_with_block_in_erb
0
+ __in_erb_template = ''
0
     form_tag("http://example.com") { concat "Hello world!" }
0
 
0
     expected = %(<form action="http://example.com" method="post">Hello world!</form>)
0
     assert_dom_equal expected, output_buffer
0
   end
0
 
0
- def test_form_tag_with_block_and_method
0
+ def test_form_tag_with_block_and_method_in_erb
0
+ __in_erb_template = ''
0
     form_tag("http://example.com", :method => :put) { concat "Hello world!" }
0
 
0
     expected = %(<form action="http://example.com" method="post"><div style='margin:0;padding:0'><input type="hidden" name="_method" value="put" /></div>Hello world!</form>)
0
@@ -88,11 +90,11 @@ class FormTagHelperTest < ActionView::TestCase
0
     actual = radio_button_tag("gender", "m") + radio_button_tag("gender", "f")
0
     expected = %(<input id="gender_m" name="gender" type="radio" value="m" /><input id="gender_f" name="gender" type="radio" value="f" />)
0
     assert_dom_equal expected, actual
0
-
0
+
0
     actual = radio_button_tag("opinion", "-1") + radio_button_tag("opinion", "1")
0
     expected = %(<input id="opinion_-1" name="opinion" type="radio" value="-1" /><input id="opinion_1" name="opinion" type="radio" value="1" />)
0
     assert_dom_equal expected, actual
0
-
0
+
0
     actual = radio_button_tag("person[gender]", "m")
0
     expected = %(<input id="person_gender_m" name="person[gender]" type="radio" value="m" />)
0
     assert_dom_equal expected, actual
0
@@ -103,13 +105,13 @@ class FormTagHelperTest < ActionView::TestCase
0
     expected = %(<select id="people" name="people"><option>david</option></select>)
0
     assert_dom_equal expected, actual
0
   end
0
-
0
+
0
   def test_select_tag_with_multiple
0
     actual = select_tag "colors", "<option>Red</option><option>Blue</option><option>Green</option>", :multiple => :true
0
     expected = %(<select id="colors" multiple="multiple" name="colors"><option>Red</option><option>Blue</option><option>Green</option></select>)
0
     assert_dom_equal expected, actual
0
   end
0
-
0
+
0
   def test_select_tag_disabled
0
     actual = select_tag "places", "<option>Home</option><option>Work</option><option>Pub</option>", :disabled => :true
0
     expected = %(<select id="places" disabled="disabled" name="places"><option>Home</option><option>Work</option><option>Pub</option></select>)
0
@@ -145,37 +147,37 @@ class FormTagHelperTest < ActionView::TestCase
0
     expected = %(<input class="admin" id="title" name="title" type="text" value="Hello!" />)
0
     assert_dom_equal expected, actual
0
   end
0
-
0
+
0
   def test_text_field_tag_size_symbol
0
     actual = text_field_tag "title", "Hello!", :size => 75
0
     expected = %(<input id="title" name="title" size="75" type="text" value="Hello!" />)
0
     assert_dom_equal expected, actual
0
   end
0
-
0
+
0
   def test_text_field_tag_size_string
0
     actual = text_field_tag "title", "Hello!", "size" => "75"
0
     expected = %(<input id="title" name="title" size="75" type="text" value="Hello!" />)
0
     assert_dom_equal expected, actual
0
   end
0
-
0
+
0
   def test_text_field_tag_maxlength_symbol
0
     actual = text_field_tag "title", "Hello!", :maxlength => 75
0
     expected = %(<input id="title" name="title" maxlength="75" type="text" value="Hello!" />)
0
     assert_dom_equal expected, actual
0
   end
0
-
0
+
0
   def test_text_field_tag_maxlength_string
0
     actual = text_field_tag "title", "Hello!", "maxlength" => "75"
0
     expected = %(<input id="title" name="title" maxlength="75" type="text" value="Hello!" />)
0
     assert_dom_equal expected, actual
0
   end
0
-
0
+
0
   def test_text_field_disabled
0
     actual = text_field_tag "title", "Hello!", :disabled => :true
0
     expected = %(<input id="title" name="title" disabled="disabled" type="text" value="Hello!" />)
0
     assert_dom_equal expected, actual
0
   end
0
-
0
+
0
   def test_text_field_tag_with_multiple_options
0
     actual = text_field_tag "title", "Hello!", :size => 70, :maxlength => 80
0
     expected = %(<input id="title" name="title" size="70" maxlength="80" type="text" value="Hello!" />)
0
@@ -226,12 +228,13 @@ class FormTagHelperTest < ActionView::TestCase
0
       submit_tag("Save", :confirm => "Are you sure?")
0
     )
0
   end
0
-
0
+
0
   def test_pass
0
     assert_equal 1, 1
0
   end
0
 
0
- def test_field_set_tag
0
+ def test_field_set_tag_in_erb
0
+ __in_erb_template = ''
0
     field_set_tag("Your details") { concat "Hello world!" }
0
 
0
     expected = %(<fieldset><legend>Your details</legend>Hello world!</fieldset>)
...
48
49
50
51
 
52
53
54
...
95
96
97
98
 
 
99
100
101
102
103
 
 
104
105
106
...
48
49
50
 
51
52
53
54
...
95
96
97
 
98
99
100
101
102
103
 
104
105
106
107
108
0
@@ -48,7 +48,7 @@ class JavaScriptHelperTest < ActionView::TestCase
0
   end
0
 
0
   def test_link_to_function_with_href
0
- assert_dom_equal %(<a href="http://example.com/" onclick="alert('Hello world!'); return false;">Greeting</a>),
0
+ assert_dom_equal %(<a href="http://example.com/" onclick="alert('Hello world!'); return false;">Greeting</a>),
0
       link_to_function("Greeting", "alert('Hello world!')", :href => 'http://example.com/')
0
   end
0
 
0
@@ -95,12 +95,14 @@ class JavaScriptHelperTest < ActionView::TestCase
0
       javascript_tag("alert('hello')", :id => "the_js_tag")
0
   end
0
 
0
- def test_javascript_tag_with_block
0
+ def test_javascript_tag_with_block_in_erb
0
+ __in_erb_template = ''
0
     javascript_tag { concat "alert('hello')" }
0
     assert_dom_equal "<script type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>", output_buffer
0
   end
0
 
0
- def test_javascript_tag_with_block_and_options
0
+ def test_javascript_tag_with_block_and_options_in_erb
0
+ __in_erb_template = ''
0
     javascript_tag(:id => "the_js_tag") { concat "alert('hello')" }
0
     assert_dom_equal "<script id=\"the_js_tag\" type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>", output_buffer
0
   end