Xu Pengcheng created JEXL-442:
---------------------------------
Summary: Global variables can't be found in template.
Key: JEXL-442
URL: https://issues.apache.org/jira/browse/JEXL-442
Project: Commons JEXL
Issue Type: Bug
Reporter: Xu Pengcheng
The following code throws an exception: JexlExample.main:24@3:1 variable 'x' is
undefined
{code:java}
JexlBuilder jexlBuilder = new JexlBuilder();
JexlEngine jexl = jexlBuilder.create();
JexlContext context = new MapContext();
String code = """
var x = 'hello';
function test() {
return `${x}`
}
test();
""";
JexlScript script = jexl.createScript(code);
Object result = script.execute(context);
System.out.println("Expression Result: " + result);{code}
but if I change to
{code:java}
return x; {code}
which works.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)