Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement missing filters #11

Closed
43 tasks done
johannhof opened this issue Feb 13, 2016 · 3 comments · Fixed by #98
Closed
43 tasks done

Implement missing filters #11

johannhof opened this issue Feb 13, 2016 · 3 comments · Fixed by #98
Labels
good first issue Help wanted!
Milestone

Comments

@johannhof
Copy link
Contributor

johannhof commented Feb 13, 2016

Feel free to grab any of those and implement! Creating filters is really straightforward, you can find more info in the README and look at the existing filters

  • append - append a string e.g. {{ 'foo' | append:'bar' }} #=> 'foobar'
  • capitalize - capitalize words in the input sentence
  • ceil -
  • date - reformat a date (syntax reference)
  • divided_by - integer division e.g. {{ 10 | divided_by:3 }} #=> 3
  • downcase - convert an input string to lowercase
  • escape - escape a string
  • escape_once - returns an escaped version of html without affecting existing escaped entities
  • first - get the first element of the passed in array
  • floor -
  • join - join elements of the array with certain character between them
  • last - get the last element of the passed in array
  • map - map/collect an array on a given property
  • minus - subtraction e.g. {{ 4 | minus:2 }} #=> 2
  • modulo - remainder, e.g. {{ 3 | modulo:2 }} #=> 1
  • newline_to_br - replace each newline (\n) with html break
  • pluralize - return the second word if the input is not 1, otherwise return the first word e.g. {{ 3 | pluralize: 'item', 'items' }} #=> 'items'
  • plus - addition e.g. {{ '1' | plus:'1' }} #=> 2, {{ 1 | plus:1 }} #=> 2
  • prepend - prepend a string e.g. {{ 'bar' | prepend:'foo' }} #=> 'foobar'
  • remove_first - remove the first occurrence e.g. {{ 'barbar' | remove_first:'bar' }} #=> 'bar'
  • remove - remove each occurrence e.g. {{ 'foobarfoobar' | remove:'foo' }} #=> 'barbar'
  • replace_first - replace the first occurrence e.g. {{ 'barbar' | replace_first:'bar','foo' }} #=> 'foobar'
  • replace - replace each occurrence e.g. {{ 'foofoo' | replace:'foo','bar' }} #=> 'barbar'
  • reverse - reverse sort the passed in array
  • round - rounds input to the nearest integer or specified number of decimals
  • size - return the size of an array or string
  • slice - slice a string. Takes an offset and length, e.g. {{ "hello" | slice: -3, 3 }} #=> llo
  • sort - sort elements of the array
  • split - split a string on a matching pattern e.g. {{ "ab" | split:"" }} #=> ['a','b']
  • strip_html - strip html from string
  • strip_newlines - strip all newlines (\n) from string
  • times - multiplication e.g {{ 5 | times:4 }} #=> 20
  • truncate - truncate a string down to x characters. It also accepts a second parameter that will append to the string e.g. {{ 'foobarfoobar' | truncate: 5, '.' }} #=> 'foob.'
  • truncatewords - truncate a string down to x words
  • upcase - convert an input string to uppercase
  • abs
  • compact
  • default
  • lstrip
  • rstrip
  • sort_natural
  • strip
  • uniq
@fiji-flo
Copy link
Contributor

missing filters from liquid:

  • abs
  • compact
  • default
  • lstrip
  • rstrip
  • sort_natural
  • strip
  • uniq

@johannhof
Copy link
Contributor Author

Thanks! I'll add them to the initial list.

@epage
Copy link
Member

epage commented May 9, 2017

Quick reference to make it easy to finish off the last ones

url_encode

url_decode

sort_natural

map

compact

concat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Help wanted!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants