<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -44,6 +44,8 @@ The following Radius tags are available when building a SearchPage:
  * `results:query` The original query term. This is sanitized for safe 
    display.
  * `results:each` Iterator for the search result collection.
+ * `results:each:excerpt` Display the relevant excerpt for this search.
+   Requires ThinkingSphinx 1.2 or higher.
  * `results:pagination` Renders pagination links for the results collection.
    Accepts optional `class`, `previous_label`, `next_label`, `inner_window`, 
    `outer_window`, and `separator` attributes which will be forwarded to</diff>
      <filename>README.md</filename>
    </modified>
    <modified>
      <diff>@@ -50,6 +50,23 @@ module SphinxSearch
       end.join(&quot;\n&quot;)
     end
 
+    # Requires ThinkingSphinx version 1.2 or higher.
+    desc %{
+      Returns the associated excerpt for each search result. Takes an optional
+      @for@ attribute that can be set to @title@ or the name of a specific page
+      part. If @for@ is omitted, the excerpt will be drawn from the concatenation
+      of all page parts. If it is set to @title@ or the name of a part, the
+      excerpted text will be limited to the page's title or the named part.
+    }
+    tag 'results:each:excerpt' do |tag|
+      content = case tag.attr['for']
+      when 'title' : tag.locals.page.title
+      when nil : tag.locals.page.parts.map(&amp;:content).join(' ')
+      else tag.locals.page.part(tag.attr['for']).try(:content) || ''
+      end
+      tag.locals.results.excerpt_for(content)
+    end
+
     desc %{
       Renders pagination for the results. Takes optional @class@, @previous_label@,
       @next_label@, @inner_window@, @outer_window@, and @separator@ attributes</diff>
      <filename>lib/sphinx_search/radius_tags.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,6 +26,31 @@ describe SphinxSearch::RadiusTags do
     end
   end
 
+  describe &quot;results:each:excerpt&quot; do
+    it &quot;should return excerpt from concatenated parts content if no `for` attr is passed&quot; do
+      @page.results = Page.search 'harmonious'
+      @page.should render('&lt;r:results:each&gt;&lt;r:excerpt /&gt;&lt;/r:results:each&gt;').matching %r{&lt;span class=&quot;match&quot;&gt;harmonious&lt;/span&gt;}
+    end
+
+    it &quot;should return excerpt from page title if `for` attr = title&quot; do
+      @page.results = Page.search pages(:searchable).title
+      @page.should render('&lt;r:results:each&gt;&lt;r:excerpt for=&quot;title&quot;/&gt;&lt;/r:results:each&gt;').matching %r{&lt;span class=&quot;match&quot;&gt;#{pages(:searchable).title}&lt;/span&gt;}
+    end
+
+    it &quot;should return excerpt from named part if `for` specifies a part&quot; do
+      @page.results = Page.search 'harmonious'
+      output = @page.send :parse, '&lt;r:results:each&gt;&lt;r:excerpt for=&quot;extended&quot;/&gt;&lt;/r:results:each&gt;'
+      output.should match(%r{&lt;span class=&quot;match&quot;&gt;harmonious&lt;/span&gt;})
+      output.should_not match(%r{Hello world!})
+    end
+
+    it &quot;should return nothing if named part does not exist&quot; do
+      @page.results = Page.search 'harmonious'
+      output = @page.send :parse, '&lt;r:results:each&gt;&lt;r:excerpt for=&quot;bogus&quot;/&gt;&lt;/r:results:each&gt;'
+      output.should be_blank
+    end
+  end
+
   describe &quot;results:count&quot; do
     it &quot;should return full count&quot; do
       @page.results = Page.search 'harmonious'</diff>
      <filename>spec/lib/search_radius_tags_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a725bc55df85edb114647feb107d0a9e06d6db40</id>
    </parent>
  </parents>
  <author>
    <name>Josh French</name>
    <email>josh@digitalpulp.com</email>
  </author>
  <url>http://github.com/digitalpulp/radiant-sphinx-search-extension/commit/d4e2d5b4b64c493a8c91716ed9ae94142e361b5c</url>
  <id>d4e2d5b4b64c493a8c91716ed9ae94142e361b5c</id>
  <committed-date>2009-07-28T11:36:12-07:00</committed-date>
  <authored-date>2009-07-28T11:35:49-07:00</authored-date>
  <message>Add excerpt support</message>
  <tree>902ac834d66c3bd52a0f0b57109a65872721aa51</tree>
  <committer>
    <name>Josh French</name>
    <email>josh@digitalpulp.com</email>
  </committer>
</commit>
