Sha256: 802f26de9b5b1dff91437de19164318a2c20ca0fe6a6a81cc508709e131bee42

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 KB

Contents

require 'RedCloth'

module Locomotive
  module Builder
    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

8 entries across 8 versions & 1 rubygems

Version Path
locomotivecms_builder-1.0.0.alpha8 lib/locomotive/builder/liquid/filters/text.rb
locomotivecms_builder-1.0.0.alpha7 lib/locomotive/builder/liquid/filters/text.rb
locomotivecms_builder-1.0.0.alpha6 lib/locomotive/builder/liquid/filters/text.rb
locomotivecms_builder-1.0.0.alpha5 lib/locomotive/builder/liquid/filters/text.rb
locomotivecms_builder-1.0.0.alpha4 lib/locomotive/builder/liquid/filters/text.rb
locomotivecms_builder-1.0.0.alpha3 lib/locomotive/builder/liquid/filters/text.rb
locomotivecms_builder-1.0.0.alpha2 lib/locomotive/builder/liquid/filters/text.rb
locomotivecms_builder-1.0.0.alpha1 lib/locomotive/builder/liquid/filters/text.rb