public
Description: Makes your models act as textiled.
Homepage: http://errtheblog.com/posts/12-actsastextiled
Clone URL: git://github.com/defunkt/acts_as_textiled.git
autolink urls and emails and preserve whitespace to support haml
lawrencepit (author)
Wed Jun 04 18:27:41 -0700 2008
commit  5b366328152d7171f178857b6166fe4a5f317150
tree    20dcf225fd916f001ef631ceadccbf9705da0b5d
parent  6a3a952e6c6287fde06b449e8a0257db4f8ef15e
...
21
22
23
24
 
 
 
 
 
 
 
 
 
 
 
25
26
27
...
21
22
23
 
24
25
26
27
28
29
30
31
32
33
34
35
36
37
0
@@ -21,7 +21,17 @@ module Err
0
               type = type.first
0
 
0
               if type.nil? && self[attribute]
0
- textiled[attribute.to_s] ||= RedCloth.new(self[attribute], Array(ruled[attribute])).to_html
0
+ t = textiled[attribute.to_s]
0
+ if t.nil?
0
+ linked = auto_link(self[attribute], :all) do |txt|
0
+ txt.size < 55 ? txt : truncate(txt, 50)
0
+ end
0
+ t = RedCloth.new(linked, Array(ruled[attribute])).to_html
0
+ # preserve whitespace for haml
0
+ t = t.chomp("\n").gsub(/\n/, '&#x000A;').gsub(/\r/, '')
0
+ textiled[attribute.to_s] = t
0
+ end
0
+ t
0
               elsif type.nil? && self[attribute].nil?
0
                 nil
0
               elsif type_options.include?(type.to_s)

Comments

    No one has commented yet.