Skip to content

Commit 9f4f756

Browse files
pashutechrisvfritz
authored andcommitted
syntax.md - first argument in filter chaining (#1045)
extended and clarified the explanation
1 parent d4d678f commit 9f4f756

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/v2/guide/syntax.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Vue.js allows you to define filters that can be used to apply common text format
132132

133133
<p class="tip">Vue 2.x filters can only be used inside mustache interpolations and `v-bind` expressions (the latter supported in 2.1.0+), because filters are primarily designed for text transformation purposes. For more complex data transforms in other directives, you should use [Computed properties](computed.html) instead.</p>
134134

135-
The filter function always receives the expression's value as the first argument.
135+
The filter function always receives the expression's value (the result of the former chain) as its first argument. In this example, the `capitalize` filter function will receive the value of `message` as its argument.
136136

137137
``` js
138138
new Vue({
@@ -153,13 +153,16 @@ Filters can be chained:
153153
{{ message | filterA | filterB }}
154154
```
155155

156+
In this case, `filterA`, defined with a single argument, will recieve the value of `message`, and then the `filterB` function will be called with the result of `filterA` passed into `filterB`'s single argument.
157+
158+
156159
Filters are JavaScript functions, therefore they can take arguments:
157160

158161
``` html
159162
{{ message | filterA('arg1', arg2) }}
160163
```
161164

162-
Here, the plain string `'arg1'` will be passed into the filter as the second argument, and the value of expression `arg2` will be evaluated and passed in as the third argument.
165+
Here `filterA` is defined as a function taking three arguments. The value of message will be passed into the first argument. The plain string `'arg1'` will be passed into the `filterA` as its second argument, and the value of expression `arg2` will be evaluated and passed in as the third argument.  
163166

164167
## Shorthands
165168

0 commit comments

Comments
 (0)