# Twig Filters Reference Acai uses Twig **filters** (with `|` pipe syntax). Never use Twig functions — only filters are supported. ## Database Queries ### `get` — Query Table ```twig {# All records #} {% set products = 'productos' | get() %} {# With WHERE #} {% set active = 'productos' | get({activo: 1}) %} {# With WHERE + ORDER + LIMIT #} {% set latest = 'noticias' | get({publicado: 1}, 'fecha DESC', 6) %} {# Single record (first result) #} {% set product = 'productos' | get({num: 42}) %} {{ product[0].nombre }} ``` ### `queryDB` — Raw SQL Query ```twig {% set results = 'SELECT * FROM cms_productos WHERE precio > 100 ORDER BY precio ASC' | queryDB() %} ``` Note: Raw SQL uses the full table name WITH `cms_` prefix. ## Module & Hook Execution ### `hook` — Execute PHP Hook ```twig {# Call hook and output result #} {{ 'hooks/module_id/' | hook({param1: 'value', param2: variable}) }} {# Capture into variable #} {% set result = 'hooks/module_id/' | hook({action: 'getData'}) %} ``` ### `module` — Render Another Module ```twig {{ 'other_module_id' | module({param1: value1}) }} ``` ## Text & Content ### `translate` — Translation ```twig {{ 'Hello' | translate }} {{ variable | translate }} ``` ### `raw` — Render HTML Without Escaping ```twig {{ record.description | raw }} ``` ### `truncate` — Text Truncation ```twig {{ record.description | truncate(150) }} ``` ### `json_decode` — Parse JSON String ```twig {% set data = jsonString | json_decode %} {{ data.key }} ``` ## Images ### `imagec` — Image Optimization/Resize ```twig {# Resize to width #} {# In srcset #} ``` ## Operators & Syntax ### Concatenation Twig uses `~` for string concatenation (not `.` or `+`): ```twig {{ 'Hello ' ~ name ~ '!' }} {% set url = '/products/' ~ product.slug ~ '/' %} ``` ### Ternary / Default ```twig {{ title | default('Default Title') }} {{ isActive ? 'active' : 'inactive' }} ``` ### Comparisons in Twig ```twig {% if items | length > 0 %} {% if type == 'premium' %} {% if name is not empty %} ``` Note: In `c-if` attributes, use `=` (single equals) for equality. In Twig `{% if %}` blocks, use `==` (double equals).