Sha256: 99a216a1feb2d823a8c48f0ab3791bda49e0087d51ab654f23cc24094f60c87a

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

module Locomotive
  module Steam
    module Liquid
      module Filters
        module Text

          # right justify and padd a string
          def rjust(input, integer, padstr = '')
            input.to_s.rjust(integer, padstr)
          end

          # left justify and padd a string
          def ljust(input, integer, padstr = '')
            input.to_s.ljust(integer, padstr)
          end

          def underscore(input)
            input.to_s.gsub(' ', '_').gsub('/', '_').underscore
          end

          def dasherize(input)
            input.to_s.gsub(' ', '-').gsub('/', '-').dasherize
          end

          # alias newline_to_br
          def multi_line(input)
            input.to_s.gsub("\n", '<br/>')
          end

          def concat(input, *args)
            result = input.to_s
            args.flatten.each { |a| result << a.to_s }
            result
          end

          def encode(input)
            Rack::Utils.escape(input)
          end

          def textile(input)
            ::RedCloth.new(input).to_html
          end

          def markdown(input)
            Locomotive::Steam::Markdown.steam(input)
          end

        end

        ::Liquid::Template.register_filter(Text)

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
locomotivecms_steam-0.1.2.pre.beta lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-0.1.1 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-0.1.0 lib/locomotive/steam/liquid/filters/text.rb