Sha256: c5de9438708512d9a78d215076e4d60abf251d0e9b1d3093b32a057d2499e0f4

Contents?: true

Size: 1.07 KB

Versions: 3

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

3 entries across 3 versions & 1 rubygems

Version Path
locomotivecms_wagon-1.2.2 lib/locomotive/wagon/liquid/filters/text.rb
locomotivecms_wagon-1.2.1 lib/locomotive/wagon/liquid/filters/text.rb
locomotivecms_wagon-1.2.0 lib/locomotive/wagon/liquid/filters/text.rb