Sha256: 01c336dd0170df7c648b39e255e60e5b01aa61371e01b9b385948e909ab0cf0a

Contents?: true

Size: 1.26 KB

Versions: 41

Compression:

Stored size: 1.26 KB

Contents

module Locomotive
  module Steam
    module Liquid
      module Filters
        module Text

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

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

          def encode(input)
            Rack::Utils.escape(input)
          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

          # 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 textile(input)
            @context.registers[:services].textile.to_html(input)
          end

          def markdown(input)
            @context.registers[:services].markdown.to_html(input)
          end

        end

        ::Liquid::Template.register_filter(Text)

      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
locomotivecms_steam-1.1.0 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.1.0.rc3 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.1.0.rc2 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.1.0.rc1 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.1 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.rc10 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.rc9 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.rc8 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.rc6 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.rc4 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.rc3 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.rc2 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.rc1 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.pre.beta.3 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.pre.beta.2 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.pre.beta.1 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.pre.alpha.3 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.pre.alpha.2 lib/locomotive/steam/liquid/filters/text.rb
locomotivecms_steam-1.0.0.pre.alpha.1 lib/locomotive/steam/liquid/filters/text.rb