From 6d7e70cec6ffb473d1d7f340cb71b17584ae114d Mon Sep 17 00:00:00 2001 From: Peep van Puijenbroek Date: Tue, 24 Feb 2026 10:08:35 +0100 Subject: [PATCH] feat: evaluate and pass keyword args to Liquid filter invocations Previously, keyword arguments parsed from filter expressions (e.g., {{ "key" | t: name: "John" }}) were stored in the filter structure but never evaluated or passed to the filter method during rendering. This change evaluates keyword args against the rendering context and appends them as the last element (map[string]interface{}) in the variadic args passed to the filter's Invoke method. --- liquid/variable.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/liquid/variable.go b/liquid/variable.go index d5ead0e..b9657a1 100644 --- a/liquid/variable.go +++ b/liquid/variable.go @@ -370,6 +370,17 @@ func (v *Variable) Render(context TagContext) interface{} { evaluatedArgs[i] = context.Evaluate(arg) } + // Evaluate keyword arguments if present (filter[2] is a map[string]interface{}) + if len(filter) > 2 { + if kwargs, ok := filter[2].(map[string]interface{}); ok && len(kwargs) > 0 { + evaluatedKwargs := make(map[string]interface{}, len(kwargs)) + for k, v := range kwargs { + evaluatedKwargs[k] = context.Evaluate(v) + } + evaluatedArgs = append(evaluatedArgs, evaluatedKwargs) + } + } + // Invoke filter value = context.Invoke(filterName, value, evaluatedArgs...) }