Sha256: ab5e3a6b2027b2a9e28576c7ecbe945ca24fd3d7834f612ed2814c2c8857f0be

Contents?: true

Size: 1014 Bytes

Versions: 6

Compression:

Stored size: 1014 Bytes

Contents

require 'redcloth'
module Waves
  module Helpers

    # Formatting helpers are used to convert specialized content, like Markaby or
    # Textile, into valid HTML. It also provides common escaping functions.
    module Formatting

      # Escape a string as HTML content.
      def escape_html(s); Rack::Utils.escape_html(s); end

      # Escape a URI, converting quotes and spaces and so on.
      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.
      def markaby( content ); self << eval( content ); end

      # Treat content as Textile.
      def textile( content )
        return if content.nil? or content.empty?
        #( ::RedCloth::TEXTILE_TAGS  << [ 96.chr, '&8216;'] ).each do |pat,ent|
        #  content.gsub!( pat, ent.gsub('&','&#') )
        #end
        self << ::RedCloth.new( content ).to_html
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
dyoder-waves-0.8.0 lib/helpers/formatting.rb
waves-edge-2009.03.10.13.14 lib/helpers/formatting.rb
waves-stable-2009.3.10 lib/helpers/formatting.rb
waves-0.8.0 lib/helpers/formatting.rb
waves-0.8.1 lib/helpers/formatting.rb
waves-0.8.2 lib/helpers/formatting.rb