Skip to content

Commit 82a6680

Browse files
committed
filters
1 parent dbbf8cb commit 82a6680

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

source/api/filters.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,28 @@ You can pass an optional argument which will be used as the currency symbol (def
2727

2828
- this filter takes at least one argument
2929

30-
*1 => '1 item'*
31-
*2 => '2 items'*
32-
33-
When there is exactly one arg, plural forms simply add an "s" at the end. When there are more than one argument, the arguments will be used as array of strings corresponding to the single, double, triple ... forms of the word to be pluralized. When the number to be pluralized exceeds the length of the args, it will use the last entry in the array.
30+
Pluralizes the argument based on the filtered value. When there is exactly one arg, plural forms simply add an "s" at the end. When there are more than one argument, the arguments will be used as array of strings corresponding to the single, double, triple ... forms of the word to be pluralized. When the number to be pluralized exceeds the length of the args, it will use the last entry in the array.
3431

3532
**Example:**
3633

3734
``` html
38-
<span v-text="date | pluralize st nd rd th"></span>
35+
{&#123;count&#125;} {&#123;count | pluralize item&#125;}
36+
```
37+
38+
*1 => '1 item'*
39+
*2 => '2 items'*
40+
41+
``` html
42+
{&#123;date&#125;}{&#123;date | pluralize st nd rd th&#125;}
3943
```
4044

4145
Will result in:
4246

43-
*1 => '1 st'*
44-
*2 => '2 nd'*
45-
*3 => '3 rd'*
46-
*4 => '4 th'*
47-
*5 => '5 th'*
47+
*1 => '1st'*
48+
*2 => '2nd'*
49+
*3 => '3rd'*
50+
*4 => '4th'*
51+
*5 => '5th'*
4852

4953
### key
5054

@@ -82,7 +86,7 @@ Make `v-repeat` only display a filtered version of the source Array. The `search
8286
``` html
8387
<input v-model="searchText">
8488
<ul>
85-
<li v-repeat="users | filterBy searchText">{&#123;name&#125;}</li>
89+
<li v-repeat="users | filterBy searchText">{&#123;name&#125;}</li>
8690
</ul>
8791
```
8892

@@ -93,7 +97,7 @@ Optionally, you can narrow down which specific property to search in with the op
9397
``` html
9498
<input v-model="searchText">
9599
<ul>
96-
<li v-repeat="users | filterBy searchText in name">{&#123;name&#125;}</li>
100+
<li v-repeat="users | filterBy searchText in name">{&#123;name&#125;}</li>
97101
</ul>
98102
```
99103

@@ -103,7 +107,7 @@ Finally, you can use quotes to indicate literal arguments:
103107

104108
``` html
105109
<ul>
106-
<li v-repeat="users | filterBy '555' in 'phone'">{&#123;name&#125;}</li>
110+
<li v-repeat="users | filterBy '555' in 'phone'">{&#123;name&#125;}</li>
107111
</ul>
108112
```
109113

@@ -118,24 +122,24 @@ Sort `v-repeat`'s displayed result. The `sortKey` argument is a property key on
118122

119123
``` html
120124
<ul>
121-
<li v-repeat="users | orderBy field reverse">{&#123;name&#125;}</li>
125+
<li v-repeat="users | orderBy field reverse">{&#123;name&#125;}</li>
122126
</ul>
123127
```
124128

125129
``` js
126130
new Vue({
127-
/* ... */
128-
data: {
129-
field: 'name',
130-
reverse: false
131-
}
131+
/* ... */
132+
data: {
133+
field: 'name',
134+
reverse: false
135+
}
132136
})
133137
```
134138

135139
You can also use quotes for literal sort key. To indicate a literal reverse, use `-1`:
136140

137141
``` html
138142
<ul>
139-
<li v-repeat="users | orderBy 'name' -1">{&#123;name&#125;}</li>
143+
<li v-repeat="users | orderBy 'name' -1">{&#123;name&#125;}</li>
140144
</ul>
141145
```

0 commit comments

Comments
 (0)