Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alih bahasa 90,99% #61

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/v2/guide/filters.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
title: Filters
title: Filter
type: guide
order: 305
---

Vue.js allows you to define filters that can be used to apply common text formatting. Filters are usable in two places: **mustache interpolations and `v-bind` expressions** (the latter supported in 2.1.0+). Filters should be appended to the end of the JavaScript expression, denoted by the "pipe" symbol:
Di Vue.js Anda dapat mendeklarasikan atau membuat kustom filter yang dapat digunakan untuk memformat teks. Filter digunakan dalam dua tempat: **mustache interpolations** dan ekspresi `v-bind` (didukung pada versi 2.1.0+). Filter harus ditambahkan pada bagian akhir atau setelahnya dengan menggunakan ekspresi JavaScript, dipisahkan dengan simbol "pipe" ( | ):

``` html
<!-- in mustaches -->
<!-- di dalam sintaks `mustaches` -->
{{ message | capitalize }}

<!-- in v-bind -->
<!-- di dalam `v-bind` -->
<div v-bind:id="rawId | formatId"></div>
```

You can define local filters in a component's options:
Anda dapat mendeklarasikan filter ke dalam opsi komponen.

``` js
filters: {
Expand All @@ -26,7 +26,7 @@ filters: {
}
```

or define a filter globally before creating the Vue instance:
atau mendeklarasikan global filter sebelum membuat *instance* Vue:

``` js
Vue.filter('capitalize', function (value) {
Expand All @@ -35,12 +35,13 @@ Vue.filter('capitalize', function (value) {
return value.charAt(0).toUpperCase() + value.slice(1)
})

// Vue Instance
new Vue({
// ...
})
```

Below is an example of our `capitalize` filter being used:
Di bawah ini contoh dari filter huruf kapital (`capitalize`) yang digunakan:

{% raw %}
<div id="example_1" class="demo">
Expand All @@ -66,20 +67,21 @@ Below is an example of our `capitalize` filter being used:
</script>
{% endraw %}

The filter's function always receives the expression's value (the result of the former chain) as its first argument. In the above example, the `capitalize` filter function will receive the value of `message` as its argument.
*Function* atau *method* filter selalu menerima nilai dari ekspresi nilai (hasil rantai pertama) sebagai argumen/parameter awal. Pada contoh di atas, filter dari fungsi `capitalize` akan menerima nilai dari `message` sebagai argumen-nya.

Filters can be chained:
Filter dapat dijadikan berantai (metode *chain*):

``` html
{{ message | filterA | filterB }}
```

In this case, `filterA`, defined with a single argument, will receive the value of `message`, and then the `filterB` function will be called with the result of `filterA` passed into `filterB`'s single argument.
Dalam hal ini, `filterA` yang dideklarasikan dengan satu argumen, akan menerima nilai dari `message`. Selanjutnya fungsi `filterB` akan dipanggil dengan hasil dari fungsi `filterA` yang dimasukkan ke dalam
`filterB` sebagai argumen tunggal.

Filters are JavaScript functions, therefore they can take arguments:
Karena filter merupakan *fungsi* atau *method Javascript*, maka dapat digunakan lebih dari satu argumen atau parameter.

``` html
{{ message | filterA('arg1', arg2) }}
```

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.
Di sini `filterA` dideklarasikan sebagai sebuah fungsi yang memiliki tiga buah argumen. Nilai atau *value* dari `message` akan dimasukkan ke dalam argumen pertama. Variabel bertipe string dari `'arg1'` akan dimasukkan ke dalam `filterA` sebagai argumen kedua, dan nilai dari ekspresi `arg2` akan dievaluasi dan dimasukkan sebagai parameter ketiga.