5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/content_o_matic/text_helper.rb', line 5
def content_o_matic(slug, options = {})
options = {} if options.nil?
= true
if options.has_key?(:print_comments)
= options.delete(:print_comments)
end
text = "<!-- Loading Content: '#{slug}' -->\n" if
begin
html_body = true
if options.has_key?(:html_body)
html_body = options.delete(:html_body)
end
res = ContentOMatic.get(slug, options)
if res.success?
if html_body
text << res.html_body
else
text << res.body
end
else
raise res.exception
end
rescue Exception => e
text << "<!-- Error: #{e.message} -->" if
end
text << "\n<!-- Loaded Content: '#{slug}' -->" if
text
end
|