Saltar al contenido principal

Referencia de filtros

Todos los filtros disponibles en los templates, organizados por categoría. Se usan con la pipe |:

{{ product.price | money_with_currency: store.currency_symbol }}
{{ product.title | upcase | truncate: 30 }}

Moneda​

FiltroFirmaDescripciónEjemplo
moneymoney(cents)Formato simple{{ 15000 | money }} → "150.00"
money_with_currencymoney_with_currency(symbol, cents)Con símbolo{{ money_with_currency "S/" 15000 }} → "S/ 150.00"
money_with_currency_shortmoney_with_currency_short(symbol, cents)Sin decimales si es entero{{ money_with_currency_short "$" 1500 }} → "$15"
money_without_currencymoney_without_currency(cents)Sin símbolo{{ 15000 | money_without_currency }} → "150.00"
currency_symbolcurrency_symbol(code)Código → símbolo{{ "PEN" | currency_symbol }} → "S/"
money_formatmoney_format(format, code, cents)Formato custom{{ money_format "{symbol} {amount}" "PEN" 15000 }}
money_localizedmoney_localized(locale, code, cents)Separadores por locale{{ money_localized "es" "PEN" 15000 }} → "150.00"

Texto​

FiltroFirmaDescripciónEjemplo
capitalizecapitalize(s)Mayúscula inicial por palabra"hola mundo" → "Hola Mundo"
upcaseupcase(s)Todo mayúsculas"hola" → "HOLA"
downcasedowncase(s)Todo minúsculas"HOLA" → "hola"
lstriplstrip(s)Recortar izquierda" hola" → "hola"
rstriprstrip(s)Recortar derecha"hola " → "hola"
trimSpacetrimSpace(s)Recortar ambos lados" hola " → "hola"
truncatetruncate(n, s)Truncar a N chars + "..."{{ "texto largo" | truncate: 5 }} → "text…"
truncatewordstruncatewords(n, s)Truncar a N palabras{{ "dos palabras más" | truncatewords: 2 }} → "dos palabras…"
replacereplace(old, new, s)Reemplazar todos{{ "a-b-c" | replace: "-", " " }} → "a b c"
replace_firstreplace_first(old, new, s)Reemplazar primera ocurrencia
removeremove(target, s)Eliminar todas las ocurrencias{{ "hola hola" | remove: "hola" }} → " "
remove_firstremove_first(target, s)Eliminar primera ocurrencia
strip_newlinesstrip_newlines(s)Eliminar \n
strip_htmlstrip_html(s)Eliminar tags HTML{{ "<b>hi</b>" | strip_html }} → "hi"
newline_to_brnewline_to_br(s)\n → <br>
escapeescape(s)Escapar HTML entities"a&b" → "a&amp;b"
escape_onceescape_once(s)Escapar sin duplicar"a&amp;b" → "a&amp;b" (no cambia)
handleizehandleize(s)Slug URL"Mi Tema Cool!" → "mi-tema-cool"
prependprepend(prefix, s)Anteponer string{{ "mundo" | prepend: "hola " }}
appendappend(suffix, s)Anteponer string{{ "hola" | append: " mundo" }}
splitsplit(sep, s)Dividir string{{ "a,b,c" | split: "," }} → ["a","b","c"]
splitLinessplitLines(s)Dividir por saltos de línea
blankblank(s)true si vacío/whitespace
presentpresent(s)true si tiene contenido
rawraw(s)Marcar como HTML seguro

URL / Encoding​

FiltroFirmaDescripciónEjemplo
url_encodeurl_encode(s)Percent-encode"hola mundo" → "hola%20mundo"
url_decodeurl_decode(s)Percent-decode
url_forurl_for(pageType, handle)Generar URL{{ url_for "product" "camisa-roja" }} → "/products/camisa-roja"
base64_encodebase64_encode(s)Base64 encode
base64_decodebase64_decode(s)Base64 decode

Hashing​

FiltroFirmaDescripción
md5md5(s)MD5 hex digest
sha1sha1(s)SHA-1 hex digest
sha256sha256(s)SHA-256 hex digest

Imagen / Media​

FiltroFirmaDescripciónEjemplo
img_urlimg_url(size, url)Agregar parámetro de tamaño{{ img_url "400x400" url }} → "url?size=400x400"
img_tagimg_tag(image)Tag <img> completo con lazy loading
img_srcsetimg_srcset(sizes, baseURL)Atributo srcset
image_urlimage_url(params, url)URL con parámetros de imagen
image_tagimage_tag(image)Alias de img_tag
asset_urlasset_url(filename)URL del asset del tema
assetasset(filename)URL fingerprinted del asset{{ "theme.css" | asset }}
asset_img_urlasset_img_url(filename)URL de asset imagen
video_tagvideo_tag(source, attrs)Tag <video> completo
external_video_urlexternal_video_url(host, videoID)URL embed YouTube/Vimeo

Array / Slice​

FiltroFirmaDescripción
firstfirst(arr)Primer elemento
lastlast(arr)Último elemento
reversereverse(arr)Array invertido
sortsort(arr)Ordenar alfabéticamente
sort_naturalsort_natural(arr)Orden natural (números)
uniquniq(arr)Eliminar duplicados
compactcompact(arr)Eliminar nil
wherewhere(field, value, arr)Filtrar donde field == value
rejectreject(field, value, arr)Inverso de where
findfind(field, value, arr)Primera coincidencia
group_bygroup_by(field, arr)Agrupar por campo
sumsum(field, arr)Sumar campo numérico
minmin(arr)Mínimo
maxmax(arr)Máximo
samplesample(n, arr)N elementos aleatorios
pushpush(elem, arr)Agregar elemento
concatconcat(arr2, arr)Concatenar arrays
sizesize(v)Longitud de array/string/map
mapmap(field, arr)Extraer campo de cada elemento

Matemáticas​

FiltroFirmaDescripción
plusplus(a, b)Suma
minusminus(a, b)Resta
timestimes(a, b)Multiplicación
divided_bydivided_by(a, b)División
modulomodulo(a, b)Módulo
absabs(n)Valor absoluto
ceilceil(n)Redondear arriba
floorfloor(n)Redondear abajo
roundround(n)Redondear al entero más cercano
at_leastat_least(n, val)Mínimo garantizado
at_mostat_most(n, val)Máximo garantizado
mulmul(a, b)Multiplicación (int64)
addadd(a, b)Suma (int64)
divdiv(a, b)División (int64, 0-safe)
int64int64(v)Cast a int64
atoiatoi(s)String a entero

Fecha / i18n​

FiltroFirmaDescripción
datedate(layout, time)Formato de fecha Go
time_agotime_ago(time)"hace 3 días" (español)
time_ago_in_wordstime_ago_in_words(time)Alias de time_ago
localize_datelocalize_date(locale, layout, time)Fecha localizada

Layouts de fecha comunes​

LayoutOutput
"2006-01-02"2024-01-15
"02/01/2006"15/01/2024
"January 2, 2006"January 15, 2024
"15:04"14:30

Peso​

FiltroFirmaDescripción
weight_with_unitweight_with_unit(unit, grams)"1.5 kg"
convert_weightconvert_weight(from, to, grams)Conversión de unidades

FiltroFirmaDescripción
link_tolink_to(url, text)Tag <a>
link_to_taglink_to_tag(tag, text)Link a colección por tag
default_paginationdefault_pagination(pagination)HTML de paginación
pluralizepluralize(singular, plural, count)Singular/plural

CSS / HTML​

FiltroFirmaDescripción
cssVarscssVars(pairs...)Bloque de variables CSS custom
cssBlockcssBlock(selector, body)Regla CSS envuelta
jsonStrjsonStr(v)JSON para contexto <script>
is_darkis_dark(hex)Check de luminancia (BT.601)
isVideoURLisVideoURL(url)Detectar .mp4/.webm/.mov
googleFontsURLgoogleFontsURL(fonts...)URL de Google Fonts CSS2

Utilidades​

FiltroFirmaDescripción
defaultdefault(fallback, value)Fallback si vacío
jsonjson(v)Serializar a JSON
inspectinspect(v)Representación debug Go
listlist(values...)Crear array
dictdict(key, val, ...)Crear map
untiluntil(n)[0, 1, ..., n-1]
seqseq(n)[1, 2, ..., n]
nownow(){Year: 2025}
yearyear(v)Extraer año
sliceslice(s, a, b)Substring
sectionBasesectionBase(id)Strip sufijo __suffix de section ID
menumenu(ctx, handle)Menú de navegación por handle
tt(lang, key)Lookup de traducción i18n

Datos de sección (parse JSON en templates)​

FiltroFirmaDescripción
parseSlidesparseSlides(raw)Parsear JSON de hero slides
sectionStrsectionStr(section, key)Obtener string de section map
galleryItemsgalleryItems(section, key)Parsear items de galería
sectionFAQItemssectionFAQItems(section, key)Parsear items de FAQ
sectionTestimonialsItemssectionTestimonialsItems(section, key)Parsear items de testimonios