> ## Documentation Index
> Fetch the complete documentation index at: https://foliant-help.iforiti.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Liquid 篩選器

> Foliant 新增的 Liquid 篩選器，用於金額、日期、文字、地址、圖片、條碼、數字和顏色。

篩選器會改變值的列印方式。您可以在值後面用管線符號加上篩選器：`{{ total_price | money }}`。您也可以串接多個篩選器：`{{ note | escape | newline_to_br }}`。Foliant 支援 Liquid 的標準篩選器（例如 `escape`、`default`、`upcase`、`date`、`plus`、`minus`、`split`、`join`、`newline_to_br`），並新增了下列篩選器。

## 金額

| 篩選器 | 範例 | 用途 |
| - | - | - |
| `money` | `{{ total_price \| money }}` | 以分為單位的金額，使用訂單的幣別 |
| `money_with_currency` | `{{ total_price \| money_with_currency }}` | 同上，並加上幣別代碼（`$1.00 USD`） |
| `money_without_currency` | `{{ total_price \| money_without_currency }}` | 只顯示數字（`1.00`） |
| `money_without_trailing_zeros` | `{{ 10000 \| money_without_trailing_zeros }}` | 省略 `.00`（`$100`） |
| `money_in` | `{{ amount \| money_in: 'EUR' }}` | 以您指定的幣別顯示金額 |

請參閱[範本中的金額與幣別](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-money-and-currency.md)。

## 日期與文字

| 篩選器 | 範例 | 用途 |
| - | - | - |
| `date` | `{{ created_at \| date: '%d %B %Y' }}` | 格式化日期，月份和星期名稱使用文件的語言。若要覆寫，請加上語言：`date: '%B', customer_locale`。 |
| `t`（也可用 `translate`、`label`） | `{{ 'subtotal' \| t }}` | 以文件語言顯示 Foliant 的文字 |
| `t_both` | `{{ 'titles.invoice' \| t_both }}` | 以文件語言及其第二語言顯示文字（「Rechnung / Invoice」） |
| `labelled` | `{{ shop.vat_number \| labelled: 'vat_number', ' · ' }}` | 在標籤後顯示值（「 · VAT number NL…」）；值為空時不顯示任何內容 |

請參閱[日期、語言與翻譯](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-dates-and-languages.md)。

## 地址、圖片與連結

| 篩選器 | 範例 | 用途 |
| - | - | - |
| `format_address` | `{{ shipping_address \| format_address }}` | 將地址分行排列，與 Shopify 的方式相同 |
| `img_url` | `{{ line_item.image \| img_url: '120x120' }}` | 指定尺寸的 Shopify 圖片：`'thumb'`、`'small'`、`'medium'`、`'large'` 或 `'120x120'` |
| `img_tag` | `{{ line_item.image \| img_url: 'thumb' \| img_tag }}` | 為圖片網址產生 `<img>` 標籤。可選擇加上替代文字和 class：`img_tag: 'Logo', 'logo'` |
| `link_to` | `{{ 'Track your order' \| link_to: order_status_url }}` | 一個連結 |

## 條碼與 QR 碼

| 篩選器 | 範例 | 用途 |
| - | - | - |
| `barcode` | `{{ line_item.sku \| barcode }}` | 條碼（除非您指定類型，例如 `'ean13'`，否則為 Code 128） |
| `qr` | `{{ order_status_url \| qr }}` | QR 碼 |

請參閱[條碼與 QR 碼](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-barcodes-and-qr-codes.md)。

## 數字與文字

| 篩選器 | 範例 | 用途 |
| - | - | - |
| `weight_with_unit` | `{{ line_item.grams \| weight_with_unit }}` | 以公克為單位的重量並加上單位：顯示公克，達 1,000 g 時顯示公斤。指定單位即可換算：`weight_with_unit: 'lb'`（`kg`、`g`、`lb` 或 `oz`） |
| `format_number` | `{{ 1234.5 \| format_number: 2 }}` | 使用文件語言分隔符號的數字（德文為 `1.234,50`） |
| `number_with_precision` | `{{ 1.2345 \| number_with_precision: 2 }}` | 指定小數位數的數字（`1.23`） |
| `pluralize` | `{{ item_count \| pluralize: 'item', 'items' }}` | 依數量顯示單數或複數字詞 |
| `handleize` | `{{ 'Hello World!' \| handleize }}` | `hello-world` |
| `strip_html` | `{{ product.description \| strip_html }}` | 移除 HTML 標籤 |
| `truncate_words` | `{{ product.description \| truncate_words: 20 }}` | 將文字縮短為指定字數 |
| `default_value` | `{{ po_number \| default_value: 'N/A' }}` | 值為空時的替代內容 |
| `json` | `{{ shipping_address \| json }}` | 以資料形式顯示值，方便您在建立範本時查看其內容 |

## 顏色

| 篩選器 | 範例 | 用途 |
| - | - | - |
| `color_mix` | `{{ shop_accent_color \| color_mix: '#ffffff', 20 }}` | 混合兩種顏色：第一種顏色佔 20% |
| `color_contrast` | `{{ shop_accent_color \| color_contrast: '#ffffff' }}` | 兩種顏色之間的對比度（1–21） |

## 程式碼片段

兩個內建程式碼片段可列印標準的 VAT 區塊：

* `{% include 'vat_breakdown' %}`：依稅率列出的 VAT 明細表。
* `{% include 'legal_notes' %}`：VAT 法律說明（反向課稅、出口、IOSS…）。

請參閱[稅務與法律](https://foliant-help.iforiti.com/zh-Hant/tax-and-legal.md)。

## 注意事項

* 程式碼編輯器會以警告標示無法辨識的篩選器。看到警告時，請檢查預覽。
* Shopify 商店佈景主題中的部分篩選器無法在文件中使用。請只使用上述篩選器和 Liquid 的標準篩選器。

## 相關文章

* [範本中的金額與幣別](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-money-and-currency.md)
* [日期、語言與翻譯](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-dates-and-languages.md)
* [條碼與 QR 碼](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-barcodes-and-qr-codes.md)
* [訂單物件與常用變數](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-order-variables.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.