refinerycms 0.9.5.11 → 0.9.5.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,7 +25,7 @@ module Refinery::HtmlTruncationHelper
25
25
 
26
26
  # Like the Rails _truncate_ helper but doesn't break HTML tags, entities, and optionally. words.
27
27
  def truncate(text, *args)
28
- return super unless args.include?(:preserve_html_tags)
28
+ return super unless ((arguments = args.dup).extract_options![:preserve_html_tags] == true) # don't ruin the current args object
29
29
  return if text.nil?
30
30
 
31
31
  options = args.extract_options!
@@ -45,12 +45,13 @@ module Refinery::HtmlTruncationHelper
45
45
  word_length = actual_length - (truncated_doc.inner_html.mb_chars.length - truncated_doc.inner_html.rindex(' '))
46
46
  truncated_doc = doc.truncate(word_length)
47
47
  end
48
-
49
- last_child = truncated_doc.children.last
50
- if last_child.inner_html.nil?
51
- truncated_doc.inner_html + omission + options[:link] if options[:link]
48
+
49
+ if (last_child = truncated_doc.children.last).inner_html.nil?
50
+ "#{truncated_doc.inner_html}#{omission}#{options[:link]}" if options[:link]
52
51
  else
53
- last_child.inner_html = last_child.inner_html.gsub(/\W.[^\s]+$/, "") + omission
52
+ logger.warn(last_child)
53
+ logger.warn(last_child.inner_html)
54
+ last_child.inner_html = "#{last_child.inner_html.gsub(/\W.[^\s]+$/, "")}#{omission}"
54
55
  last_child.inner_html += options[:link] if options[:link]
55
56
  truncated_doc
56
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5.11
4
+ version: 0.9.5.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Resolve Digital