From c7ac7376234efcf624d98e5b9432d776fd63820b Mon Sep 17 00:00:00 2001 From: pashute Date: Tue, 25 Jul 2017 16:50:42 +0300 Subject: [PATCH] syntax.md - first argument in filter chaining extended and clarified the explanation --- src/v2/guide/syntax.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/v2/guide/syntax.md b/src/v2/guide/syntax.md index bb8bbe89c6..bd007defb1 100644 --- a/src/v2/guide/syntax.md +++ b/src/v2/guide/syntax.md @@ -132,7 +132,7 @@ Vue.js allows you to define filters that can be used to apply common text format

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.

-The filter function always receives the expression's value as the first argument. +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. ``` js new Vue({ @@ -153,13 +153,16 @@ Filters can be chained: {{ message | filterA | filterB }} ``` +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. + + Filters are JavaScript functions, therefore they can take arguments: ``` html {{ message | filterA('arg1', arg2) }} ``` -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. +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.   ## Shorthands