pug4j icon indicating copy to clipboard operation
pug4j copied to clipboard

Graal parsing error on JS syntax

Open ibrahimatcha opened this issue 1 year ago • 1 comments

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

ibrahimatcha avatar Dec 12 '23 11:12 ibrahimatcha

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

chbloemer avatar Jan 04 '24 15:01 chbloemer