0

v4 provides an API: ST.add(String, Object). I couldn't find the v3 API setAttributes(Object) in v4.

I used ST.add("root", JSONObject). An exception occures:

java.lang.IllegalArgumentException: no such attribute: root
        at org.stringtemplate.v4.ST.add(ST.java:223)
        at jjs.stst.STStandaloneTool.invokeTemplate(STStandaloneTool.java:479)
        at jjs.stst.STStandaloneTool.generate(STStandaloneTool.java:420)
        at jjs.stst.STStandaloneTool.main(STStandaloneTool.java:722)

1 Answers1

0

I had the same problem. This error occures when template is not anonymouse and doesn't expect any formal arguments. You could add this arguments yourself but its not comfortable.

Problem can be bypassed by setting ST.impl.HasFormalArgs to false and using ST.add