-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathpolymer-filters.html
259 lines (149 loc) · 4.37 KB
/
polymer-filters.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<link rel="import" href="../polymer/polymer.html">
<script src="filter-capitalize.js"></script>
<script src="filter-currency.js"></script>
<script src="filter-date.js"></script>
<script src="filter-firstlast.js"></script>
<script src="filter-length.js"></script>
<script src="filter-limitFrom.js"></script>
<script src="filter-limitTo.js"></script>
<script src="filter-list.js"></script>
<script src="filter-lowercase.js"></script>
<script src="filter-ltrim.js"></script>
<script src="filter-objectkeys.js"></script>
<script src="filter-orderBy.js"></script>
<script src="filter-random.js"></script>
<script src="filter-replace.js"></script>
<script src="filter-reverse.js"></script>
<script src="filter-round.js"></script>
<script src="filter-rtrim.js"></script>
<script src="filter-startsWith.js"></script>
<script src="filter-titlecase.js"></script>
<script src="filter-trim.js"></script>
<script src="filter-truncate.js"></script>
<script src="filter-typeof.js"></script>
<script src="filter-uppercase.js"></script>
<script src="filter-underscore.js"></script>
<script src="filter-wordcount.js"></script>
<!--
A collection of filters for formatting values of [Polymer expressions](http://www.polymer-project.org/docs/polymer/expressions.html) for display to users.
### 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!
####Underscore
{{ "UserName" | underscore }}
> user_name
{{ "User" | underscore }}
> user
####Object.keys
{{{x: 1, y: 2} | objectKeys}}
> ["x", "y"]
####Currency
{{ 169535.216 | currency }}
> $169,535.22
{{ 169535.216 | currency('USD$') }}
> USD$169,535.22
{{ 169535.216 | currency('USD$', 4) }}
> USD$169,535.2160
####typeof
{{ 'STRING' | typeof }}
> string
{{ 192.168 | typeof }}
> number
{{ {} | typeof }}
> object
{{ [] | typeof }}
> array
{{ error | typeof }}
> error
{{ regexp | typeof }}
> regexp
{{ undefined | typeof }}
> undefined
{{ null | typeof }}
> null
@element polymer-filters
@blurb A collection of Polymer filters for formatting values of expressions for display to users
@homepage http://github.com/addyosmani/polymer-filters
@inspiration http://jinja.pocoo.org/docs/templates/
-->