liquid-filters-lite

Standard Filters for Liquid template engine

npm install liquid-filters-lite
13 downloads in the last month
@version    0.0.7
@date       2014-03-16
@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'
  • remove_first - remove the first occurrence e.g. {{ 'barbar' | remove_first:'bar' }} #=> 'bar'
  • split - split a string on a matching pattern e.g. {{ "a~b" | 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 - capitalized CamelCase
  • camelback - camelBa:ck notation
  • humanTime - {{ "13" | humanTime }} #=> "13 seconds", {{ "78" | humanTime }} #=> "1 minute"
  • toAccuracy - {{ "71" | toAccuracy:5 }} #=> "70", {{ "12.31" | toAccuracy: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

Browser Support

browser support

Licence

Copyright (c) 2012 Lauri Rooden <lauri@rooden.ee>
The MIT License

npm loves you