class Humpyard::Elements::TextElement

Humpyard::Elements::TextElement is a model of a text element.

Public Instance Methods

html_content(options = {}) click to toggle source
   # File app/models/humpyard/elements/text_element.rb
15 def html_content(options = {})
16   if content.blank?
17     html = ''
18   else
19     if Object.const_defined?('RedCloth')
20       html = RedCloth.new(content).to_html
21     else
22       html = content.gsub("\n", "<br />")
23     end
24   end
25   
26   unless html.blank?
27     html = Humpyard.uri_parser.substitute html if options[:parse_uris]
28     
29     html.gsub(/(href="[a-z]*:\/\/)/,'target="blank" \1').html_safe
30   else
31     ''
32   end
33 end
html_content=(content) click to toggle source
   # File app/models/humpyard/elements/text_element.rb
35 def html_content= content
36   if content.blank?
37     self.content = ''
38   else
39     if Object.const_defined?('RedCloth')
40       require 'html_to_textile'           
41       self.content = HtmlToTextile.new(content.gsub("\n", ' ')).to_textile
42     else
43       self.content = content.gsub(/<br[^>]*>/, "\n").gsub(/<[^>]*>/, '')
44     end
45   end
46 end