<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,11 @@
 *Edge*
 
+* Added block-call style to link_to [Sam Stephenson/DHH]. Example:
+
+    &lt;% link_to(@profile) do %&gt;
+      &lt;strong&gt;&lt;%= @profile.name %&gt;&lt;/strong&gt; -- &lt;span&gt;Check it out!!&lt;/span&gt;
+    &lt;% end %&gt;
+
 * Performance: integration test benchmarking and profiling.  [Jeremy Kemper]
 
 * Make caching more aware of mime types. Ensure request format is not considered while expiring cache.  [Jonathan del Strother]</diff>
      <filename>actionpack/CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -90,6 +90,13 @@ module ActionView
       # link will be used in place of a referrer if none exists. If nil is passed as
       # a name, the link itself will become the name.
       #
+      # ==== Signatures
+      #
+      #   link_to(name, options = {}, html_options = nil)
+      #   link_to(options = {}, html_options = nil) do
+      #     # name
+      #   end
+      #
       # ==== Options
       # * &lt;tt&gt;:confirm =&gt; 'question?'&lt;/tt&gt; - This will add a JavaScript confirm
       #   prompt with the question specified. If the user accepts, the link is
@@ -147,6 +154,13 @@ module ActionView
       #   link_to &quot;Profiles&quot;, :controller =&gt; &quot;profiles&quot;
       #   # =&gt; &lt;a href=&quot;/profiles&quot;&gt;Profiles&lt;/a&gt;
       #
+      # You can use a block as well if your link target is hard to fit into the name parameter. ERb example:
+      #
+      #   &lt;% link_to(@profile) do %&gt;
+      #     &lt;strong&gt;&lt;%= @profile.name %&gt;&lt;/strong&gt; -- &lt;span&gt;Check it out!!&lt;/span&gt;
+      #   &lt;% end %&gt;
+      #   # =&gt; &lt;a href=&quot;/profiles/1&quot;&gt;&lt;strong&gt;David&lt;/strong&gt; -- &lt;span&gt;Check it out!!&lt;/span&gt;&lt;/a&gt;
+      #
       # Classes and ids for CSS are easy to produce:
       #
       #   link_to &quot;Articles&quot;, articles_path, :id =&gt; &quot;news&quot;, :class =&gt; &quot;article&quot;
@@ -189,27 +203,37 @@ module ActionView
       #        f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;
       #        var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); 
       #        m.setAttribute('value', 'delete'); f.appendChild(m);f.submit(); };return false;&quot;&gt;Delete Image&lt;/a&gt;
-      def link_to(name, options = {}, html_options = nil)
-        url = case options
-          when String
-            options
-          when :back
-            @controller.request.env[&quot;HTTP_REFERER&quot;] || 'javascript:history.back()'
+      def link_to(*args, &amp;block)
+        if block_given?
+          options      = args.first || {}
+          html_options = args.second
+          concat(link_to(capture(&amp;block), options, html_options))
+        else
+          name         = args.first
+          options      = args.second || {}
+          html_options = args.third
+
+          url = case options
+            when String
+              options
+            when :back
+              @controller.request.env[&quot;HTTP_REFERER&quot;] || 'javascript:history.back()'
+            else
+              self.url_for(options)
+            end
+
+          if html_options
+            html_options = html_options.stringify_keys
+            href = html_options['href']
+            convert_options_to_javascript!(html_options, url)
+            tag_options = tag_options(html_options)
           else
-            self.url_for(options)
+            tag_options = nil
           end
-
-        if html_options
-          html_options = html_options.stringify_keys
-          href = html_options['href']
-          convert_options_to_javascript!(html_options, url)
-          tag_options = tag_options(html_options)
-        else
-          tag_options = nil
+      
+          href_attr = &quot;href=\&quot;#{url}\&quot;&quot; unless href
+          &quot;&lt;a #{href_attr}#{tag_options}&gt;#{name || url}&lt;/a&gt;&quot;
         end
-        
-        href_attr = &quot;href=\&quot;#{url}\&quot;&quot; unless href
-        &quot;&lt;a #{href_attr}#{tag_options}&gt;#{name || url}&lt;/a&gt;&quot;
       end
 
       # Generates a form containing a single button that submits to the URL created</diff>
      <filename>actionpack/lib/action_view/helpers/url_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -211,6 +211,14 @@ class UrlHelperTest &lt; ActionView::TestCase
   def test_link_tag_using_post_javascript_and_popup
     assert_raises(ActionView::ActionViewError) { link_to(&quot;Hello&quot;, &quot;http://www.example.com&quot;, :popup =&gt; true, :method =&gt; :post, :confirm =&gt; &quot;Are you serious?&quot;) }
   end
+
+  def test_link_tag_using_block
+    self.output_buffer = ''
+
+    link_to(&quot;http://example.com&quot;) { concat(&quot;Example site&quot;) }
+
+    assert_equal '&lt;a href=&quot;http://example.com&quot;&gt;Example site&lt;/a&gt;', output_buffer
+  end
   
   def test_link_to_unless
     assert_equal &quot;Showing&quot;, link_to_unless(true, &quot;Showing&quot;, :action =&gt; &quot;show&quot;, :controller =&gt; &quot;weblog&quot;)</diff>
      <filename>actionpack/test/template/url_helper_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>22af62cf486721ee2e45bb720c42ac2f4121faf4</id>
    </parent>
  </parents>
  <author>
    <name>David Heinemeier Hansson</name>
    <login>dhh</login>
    <email>david@loudthinking.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/8190bce8bc7249b7b9f3680195336eb3ca9508ee</url>
  <id>8190bce8bc7249b7b9f3680195336eb3ca9508ee</id>
  <committed-date>2008-06-17T15:37:29-07:00</committed-date>
  <authored-date>2008-06-17T12:01:37-07:00</authored-date>
  <message>Added block-call style to link_to [Sam Stephenson/DHH]</message>
  <tree>f159b343e4893f08da5f9a3d92e1c88783323a83</tree>
  <committer>
    <name>David Heinemeier Hansson</name>
    <login>dhh</login>
    <email>david@loudthinking.com</email>
  </committer>
</commit>
