Releases: addyosmani/polymer-filters
0.2.1
0.2.0
This releases bumps our dependencies and includes a new filter for transforming camelCase keywords to underscores inside of Polymer expressions.
0.1.1
This is a maintenance release of polymer-filters with the following changes:
Polymer Filters 0.1.0
A collection of Polymer filters for formatting values of expressions for display to users. If you're used to using filters in AngularJS, this brings a similar set of concepts to Polymer.
This is the first stable version of Polymer Filters and takes the collection of filters up to 21.
New filters include:
- dc5e1a4 Capitalization filter (@florianv)
- d61369e Left and right only trimming capabilities (Marcos Placona)
Per a request from the community, the package is now also available on Bower:
bower install polymer-filters
Demo
Demos and documentation can be found over on the component page.
Examples
Uppercase
{{'Hello World' | uppercase}}
HELLO WORLD
Lowercase
{{'Hello World' | lowercase}}
hello world
Reverse
{{'Hello World' | reverse}}
dlroW olleH
Replace
{{'Hello World' | replace('World','Peeps')}}
Hello Peeps
LTrim
{{' I was a string with leading whitespace' | ltrim}}
I was a string with leading whitespace
RTrim
{{'I was a string with trailing whitespace ' | rtrim}}
I was a string with trailing whitespace
Trim
{{' I was a string with leading and trailing whitespace ' | trim}}
I was a string with leading and trailing whitespace
Truncate
{{'Lorem Catsum Itsum' | truncate(8) }}
Lorem...
{{'Lorem Catsum Itsum' | truncate(8, true) }}
Lorem Ca...
{{'Lorem Catsum Itsum' | truncate(8, true, ' [READ MORE]') }}
Lorem Ca [READ MORE]
Title case
{{'this is a sentence that was not using title case.' | titlecase}}
This Is A Sentence That Was Not Using Title Case.
Date
{{1288323623006 | date('yyyy-MM-dd HH:mm:ss Z')}}
2010-10-29 04:40:23 Z
Order an array by the expression predicate
<template repeat="{{friends | orderBy('age')}}">
{{name}}
</template>
Paul Eric Rob Timothy
Filter by items starting with a specific letter
<template repeat="{{friend in friends | startsWith('T')}}">
{{ friend.name }}
</template>
Timothy
Limit selection to a specified number of elements
<template repeat="{{friends | limitTo(2)}}">
{{name}}
</template>
Matt
Paul
Limit displayed items from an array at an offset by a limit
<template repeat="{{friends | limitFrom(1,2)}}">
{{name}}
</template>
Paul
Word count
{{'Hello World' | wordcount}}
2
First
{{ colorsArray | first }}
red
Last
{{ colorsArray | last }}
yellow
Random
{{ colorsArray | random }}
green
Length
{{'Hello World' | length}}
11
Rounding
{{ 45.35 | round }}
45
{{ 45.35 | round(1, 'floor') }}
45.3
Converting arrays to a list
{{ arr | list }}
something,somethingelse,etc
{{ arr | list(" ") }}
something, somethingelse, etc
Capitalize
{{ "Hello World!" | capitalize }}
Hello world!
Filters 0.0.3
We're now up to 18 filters in the Polymer filters collection and all filters can be seen over on our component page. This release includes a limitTo()
filter based on the AngularJS filter of the same name. Credit goes to the Angular team for their implementation, which was mostly ported over.
limitTo()
creates new arrays or strings which contain only a specified number of entries. Entries are usually taken from the start or end of a source, depending on the value and sign of the limit specified.
A quick demo can be found here
Filters 0.0.2
v0.0.2 0.0.2