# 过滤器

> Liquid filters 如何修改 Shoplazza Theme 的输出：filter 写法、传参方式、多个 filter 串联，以及按类别划分的 filter 分组。

Liquid filters 用于修改 Liquid 的输出。使用本节内容了解 filters 如何转换值、接收参数，以及如何在同一个输出表达式中组合使用。

* [Array filters](./array-filters)

## 使用方式

要对输出应用 filters，请在输出的花括号分隔符 `{{ }}` 内，在管道符 `|` 之后添加 filter 及其参数。在下面的示例中，`product` 是 object，`title` 是其属性，`upcase` 是正在应用的 filter。

```liquid title="代码"
{{ product.title | upcase }}
```
```json title="数据"
{
  "product": {
    "title": "Ace Cashmere Beanie"
  }
}
```

```html title="输出"
ACE CASHMERE BEANIE
```

## 带参数的 filters

许多 filters 接受参数，用于指定 filter 的应用方式。某些 filters 可能需要参数才能生效。

```liquid title="代码"
{{ product.title | remove: 'Ace' }}
```
```json title="数据"
{
  "product": {
    "title": "Ace Cashmere Beanie"
  }
}
```

```html title="输出"
Cashmere Beanie
```

## 使用多个 filters

多个 filters 可以应用于同一个输出，它们按从左到右的顺序依次应用。

```liquid title="代码"
{{ product.title | upcase | remove: 'ACE' }}
```
```json title="数据"
{
  "product": {
    "title": "Ace Cashmere Beanie"
  }
}
```

```html title="输出"
CASHMERE BEANIE
```
