Sha256: ceedb188adf5f8c31d92b1c6554dd8a8d570d852814ac8c834b48cf7fba297a5
Contents?: true
Size: 1004 Bytes
Versions: 5
Compression:
Stored size: 1004 Bytes
Contents
module Liquid module Rails module TextFilter delegate \ :highlight, :excerpt, :pluralize, :word_wrap, :simple_format, to: :h # 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 def concat(input, *args) result = input.to_s args.flatten.each { |a| result << a.to_s } result end private def h @h ||= @context.registers[:view] end end end end Liquid::Template.register_filter(Liquid::Rails::TextFilter)
Version data entries
5 entries across 5 versions & 2 rubygems