summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorhukl <hukl@eight.local>2009-02-02 00:37:42 +0100
committerhukl <hukl@eight.local>2009-02-02 00:37:42 +0100
commit5a8c9154d504c5376e807716c0cfcb76ef766d88 (patch)
tree275cda086ee20ce5a658fdd1425f421a7b8f6f5e /app
parent7a5555b1ac542e5fd5680cefaba3574677ecaa46 (diff)
made the whole aggregate helper exception safe by
always falling back to the original content if something went wrong. only executing substitution if tag is found
Diffstat (limited to 'app')
-rw-r--r--app/helpers/content_helper.rb23
1 files changed, 14 insertions, 9 deletions
diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb
index 046a2db..3cf3488 100644
--- a/app/helpers/content_helper.rb
+++ b/app/helpers/content_helper.rb
@@ -7,17 +7,22 @@ module ContentHelper
7 def aggregate? content 7 def aggregate? content
8 options = {} 8 options = {}
9 9
10 if content =~ /<aggregate([^<>]*)>/ 10 begin
11 tag = $~.to_s 11 if content =~ /<aggregate([^<>]*)>/
12 matched_data = $1.scan(/\w+\=\"[a-zA-Z\s\/_\d]*\"/) 12 tag = $~.to_s
13 13 matched_data = $1.scan(/\w+\=\"[a-zA-Z\s\/_\d]*\"/)
14 matched_data.each do |data| 14
15 splitted_data = data.split("=") 15 matched_data.each do |data|
16 options[splitted_data[0].to_sym] = splitted_data[1].gsub(/\"/, "") 16 splitted_data = data.split("=")
17 options[splitted_data[0].to_sym] = splitted_data[1].gsub(/\"/, "")
18 end
19
20 content.sub(tag, render_collection(options))
17 end 21 end
22
23 rescue
24 content
18 end 25 end
19
20 content.sub(tag, render_collection(options))
21 end 26 end
22 27
23 def render_collection options 28 def render_collection options