Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.
/ liquid-filters-lite Public archive

DEPRECATED! Standard Filters for liquid-lite extending native prototypes

Notifications You must be signed in to change notification settings

litejs/liquid-filters-lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@version    0.1.5
@date       2015-04-09
@stability  2 - Unstable

Liquid Filters – Build Coverage

Standard Filters for liquid-lite extending native prototypes.

Currently supported filters

  • date - reformat a date syntax reference
    Require date-format-lite

    var item = { "timestamp": 1363770186, "datetime": "2013-03-20T09:03:06Z" }
    {{ timestamp | date:"isoUtcDateTime" }}
    {{ datetime | date:"hh:mm" }}
  • capitalize - capitalize words in the input sentence

  • downcase - convert an input string to lowercase

  • upcase - convert an input string to uppercase

  • first - get the first element of the passed in array

  • last - get the last element of the passed in array

  • join - join elements of the array with certain character between them. Native in javascript

  • sort - sort elements of the array Native in javascript

  • size - return the size of an array or string

  • replace - replace the first or each occurrence. Native in javascript

    {{ 'foofoo' | replace:'foo','bar' }} #=> 'barfoo'
    {{ 'foofoo' | replace:/foo/g,'bar' }} #=> 'barbar'
  • remove - remove each occurrence e.g. {{ 'foobarfoobar' | remove:'foo' }} #=> 'barbar'

  • split - split a string on a matching pattern e.g. {{ "ab" | split: }} #=> ['a','b']. Native in javascript

  • pluck - map/collect an array on a given property

  • truncate - truncate a string down to x characters

  • truncatewords - truncate a string down to x words

  • camelCase - camelCase notation

  • humanTime - {{ "13" | humanTime }} #=> "13 seconds", {{ "78" | humanTime }} #=> "1 minute"

  • step - {{ "71" | step:5 }} #=> "70", {{ "12.31" | step:0.2 }} #=> "12.4"

Todo

  • escape - escape a string
  • escape_once - returns an escaped version of html without affecting existing escaped entities
  • strip_html - strip html from string
  • prepend - prepend a string e.g. {{ 'bar' | prepend:'foo' }} #=> 'foobar'
  • append - append a string e.g. {{ 'foo' | append:'bar' }} #=> 'foobar'
  • minus - subtraction e.g. {{ 4 | minus:2 }} #=> 2
  • plus - addition e.g. {{ '1' | plus:'1' }} #=> '11', {{ 1 | plus:1 }} #=> 2
  • times - multiplication e.g {{ 5 | times:4 }} #=> 20
  • divided_by - division e.g. {{ 10 | divided_by:2 }} #=> 5
  • modulo - remainder, e.g. {{ 3 | modulo:2 }} #=> 1

External links

Licence

Copyright (c) 2012 Lauri Rooden <[email protected]>
The MIT License

About

DEPRECATED! Standard Filters for liquid-lite extending native prototypes

Resources

Security policy

Stars

Watchers

Forks