Sha256: 5882a68e83093994002cc160355b45fc05cfc5e0d1d75d408c12f32784d12a10
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
module EtabliocmsCore::OutputHelper def html_out(obj, method = "text", options = {}) return "" if obj.nil? string = obj.send(method) string = RedCloth.new(string.to_s) string = string.to_html(:textile, :tags) string = truncate_and_strip_tags(string, options[:words].to_i) if options[:words] string = string.gsub(/\\|"/) { |c| "\\#{c}" } if options[:escape_double_quote] string.html_safe end def sanitized(string) simple_format(auto_link(h(string))) end def truncate_words(text, wordcount = 30, separator = "…") text.to_s.split[0..(wordcount-1)].join(" ") +(text.to_s.split.size > wordcount ? separator : "") end def truncate_and_strip_tags(text, wordcount = 30, separator = "…") truncate_words(strip_tags(text.to_s), wordcount, separator) end def truncate_and_strip_tags_from_textile(textile, wordcount = 30, separator = "…") truncate_words(strip_tags(RedCloth.new(textile.to_s).to_html), wordcount, separator) end def w3c_date(date) date.utc.strftime("%Y-%m-%dT%H:%M:%S+00:00") end end
Version data entries
3 entries across 3 versions & 1 rubygems