Sha256: 4dc22d43219b662a3827a984b422236457ba5ff8ec3d965b63ee8a09aae0a68a

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

require 'RedCloth'

module Locomotive
  module Wagon
    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 textile(input)
            ::RedCloth.new(input).to_html
          end

        end

        ::Liquid::Template.register_filter(Text)

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
locomotivecms_wagon-1.1.0 lib/locomotive/wagon/liquid/filters/text.rb
locomotivecms_wagon-1.0.2 lib/locomotive/wagon/liquid/filters/text.rb
locomotivecms_wagon-1.0.1 lib/locomotive/wagon/liquid/filters/text.rb
locomotivecms_wagon-1.0.0 lib/locomotive/wagon/liquid/filters/text.rb