bkiers / Liqp

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

Template errors not being stored when using liquid for loops #260

Closed rmurthy1996 closed 1 year ago

rmurthy1996 commented 1 year ago

I'm trying to test a liquid for loop where the variables do not exist. I want to render the text without throwing an error but still capture the error list. This is the case I'm testing:

String text = "{% for product in products %} {{product.image}} {% endfor %}";
Template template =
                Template.parse(text)
                        .withRenderSettings(
                                new RenderSettings.Builder()
                                        .withStrictVariables(true)
                                        .withRaiseExceptionsInStrictMode(false)
                                        .build());
template.render(Map.of());
System.out.println(template.errors());

--> prints empty list []

This runs without throwing as expected but the final error list is empty when I would expect it to contain any suppressed errors. If I were to remove the looping logic and simply have for example {{product.image}} as my text, then the error list populates as expected. I'm curious why the looping logic in the text is preventing the error list from populating?

rmurthy1996 commented 1 year ago

tagging for vis: @kohlschuetter @bkiers

msangel commented 1 year ago

Closed in https://github.com/bkiers/Liqp/pull/261