When rendering the contents of truncate_and_strip tag, the length of the output may be limited by the "limit" attribute, which is optional. Looking at the source, it seems that this limit should be 100 by default. However, (tag.attrlength?.to_i
100) evaluates as '0 ' when the length attribute is not specified, thus producing unlimited output.
Proposed patch:
diff -bu search_page.rb search_page_patched.rb
--- search_page.rb 2007-05-11 03:59:02.000000000 +0200
+++ search_page_patched.rb 2007-09-20 15:41:52.000000000 +0200
@@ -50,7 +50,8 @@
Useful for displaying a snippet of a found page. The optional `length' attribute
specifies how many characters to truncate to.}
tag 'truncate_and_strip' do |tag|
- length = tag.attr["length"].to_i || 100
+ tag.attr["length"] ||= 100
+ length = tag.attr["length"].to_i
helper = ActionView::Base.new
helper.truncate(helper.strip_tags(tag.expand).gsub(/\s+/," "), length)
end
Change History
Download in other formats:
|