neuland / pug4j

a pug implementation written in Java (formerly known as jade)
MIT License
61 stars 12 forks source link

Graal parsing error on JS syntax #25

Open ibrahimatcha opened 11 months ago

ibrahimatcha commented 11 months ago

Hi,

This is my usage of Pug4J:

PugTemplate template;
PugConfiguration config = new PugConfiguration();
config.setExpressionHandler(new GraalJsExpressionHandler());
try {
        template = config.getTemplate("src/main/resources/template/pdf-body.template.pug");
} catch (IOException e) {
        logger.error("Error getting PUG template");
        throw new RuntimeException(e);
}

HashMap<String, Object> objects = new HashMap<>();
objects.put("vehicleCheck", vehicleCheck);
objects.put("summary", summary);
objects.put("mileageGraph", mileageGraph);

return config.renderTemplate(template, objects);

When it tried running the getTemplate code, it produces an exception with this message: Syntax Error: unable to evaluate [summary.issues().status() === 'NO_ISSUES'] - Parsing de.neuland.pug4j.expression.JexlExpressionHandler.assertExpression@1:29 parsing error in '='

It is complaining about the === which is pure JS syntax so I'm confused what the issue is since I'm using the GraalJsExpressionHandler. Please advise

chbloemer commented 11 months ago

Until pug4j 2.0.3 Jexl was still used for assertions. 2.0.4 and up should be GraalsJS only.