bkiers / Liqp

An ANTLR based 'Liquid Template' parser and rendering engine.
MIT License
165 stars 94 forks source link

How to modify default renderer #268

Closed ktalebian closed 1 year ago

ktalebian commented 1 year ago

Can the default render of the parser be changed? For example, take a look at the following:

Template.parse("{{context}}").render(Map.of("context", List.of("1", "2", "3")))
// prints "123"

Template.parse("{{context}}").render(Map.of("context", List.of(Map.of("key1", "value1"), Map.of("key2", "value2"))))
// prints "{key1=value1}{key2=value2}

Template.parse("{{context}}").render(Map.of("context",Map.of("key1", "value1", "key2", "value2")))
// prints "{key1=value1, key2=value2}

I want to control what the toString here is by default. I know I can create my filter toJson and then have {{context | toJson}}, but I want this to be the default behaviour.

msangel commented 1 year ago

Hello @ktalebian This library is an implementation of Liquid templating engine in Java. If the requested feature does not exist in the original ruby library, small chance it will be implemented here.