You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ST.format("name, phone | <name>:<phone>", n, p);
ST.format("<%1>:<%2>", n, p);
ST.format("<name>:<phone>", "name", x, "phone", y);
But that example statements do not work as expected:
import org.stringtemplate.v4.ST;
public class Main {
public static void main(String[] args) {
String n = "n";
String p = "p";
String x = "x";
String y = "y";
System.out.println(ST.format("name, phone | <name>:<phone>", n, p));
System.out.println(ST.format("<%1>:<%2>", n, p));
System.out.println(ST.format("<name>:<phone>", "name", x, "phone", y));
}
}
results in the following output:
context [anonymous] 1:15 attribute name isn't defined
name, phone | :
n:p
:
context [anonymous] 1:22 attribute phone isn't defined
context [anonymous] 1:1 attribute name isn't defined
context [anonymous] 1:8 attribute phone isn't defined
How should ST.format() be used?
The text was updated successfully, but these errors were encountered:
In the Java API doc of
ST.format()
the following example code statements can be seen:But that example statements do not work as expected:
results in the following output:
How should
ST.format()
be used?The text was updated successfully, but these errors were encountered: