| Module | Waves::Helpers::Formatting |
| In: |
lib/helpers/formatting.rb
|
Formatting helpers are used to convert specialized content, like Markaby or Textile, into valid HTML. It also provides common escaping functions.
Escape a string as HTML content.
# File lib/helpers/formatting.rb, line 10
10: def escape_html(s); Rack::Utils.escape_html(s); end
Escape a URI, converting quotes and spaces and so on.
# File lib/helpers/formatting.rb, line 13
13: def escape_uri(s); Rack::Utils.escape(s); end
Treat content as Markaby and evaluate (only works within a Markaby template). Used to pull Markaby content from a file or database into a Markaby template.
# File lib/helpers/formatting.rb, line 17
17: def markaby( content ); self << eval( content ); end
Treat content as Textile.
# File lib/helpers/formatting.rb, line 20
20: def textile( content )
21: return if content.nil? or content.empty?
22: #( ::RedCloth::TEXTILE_TAGS << [ 96.chr, '&8216;'] ).each do |pat,ent|
23: # content.gsub!( pat, ent.gsub('&','&#') )
24: #end
25: self << ::RedCloth.new( content ).to_html
26: end