Sha256: 889a86de015926e77518bfa4485102494d62c63399d0002b1a243677698c6dbd
Contents?: true
Size: 661 Bytes
Versions: 11
Compression:
Stored size: 661 Bytes
Contents
require 'json' module Liquid module Rails module MiscFilter # Get the nth element of the passed in array def index(array, position) array.at(position) if array.respond_to?(:at) end def random(input) rand(input.to_i) end def jsonify(object) JSON.dump(object) end # If condition is true, the class_name is returned. Otherwise, it returns nil. # class_name: css class name # condition: boolean def toggle_class_name(class_name, condition) condition ? class_name : nil end end end end Liquid::Template.register_filter(Liquid::Rails::MiscFilter)
Version data entries
11 entries across 11 versions & 4 rubygems