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.
|
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
|
-
|
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
|
-
|
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
|