Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ST.format() Javadoc examples not with expected result #113

Closed
chwt opened this issue May 18, 2015 · 2 comments
Closed

ST.format() Javadoc examples not with expected result #113

chwt opened this issue May 18, 2015 · 2 comments
Assignees
Milestone

Comments

@chwt
Copy link

chwt commented May 18, 2015

In the Java API doc of ST.format() the following example code statements can be seen:

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?

@parrt
Copy link
Member

parrt commented May 19, 2015

dang. i saw something similar myself recently. i must have added a regression recently. sorry.

@parrt parrt added the type:bug label May 19, 2015
@sharwell
Copy link
Member

@parrt I can't find any indication that ST.format ever supported any form except the one with positional arguments.

@sharwell sharwell added this to the 4.0.9 milestone Jul 17, 2016
@sharwell sharwell self-assigned this Jul 17, 2016
sharwell added a commit to sharwell/stringtemplate4 that referenced this issue Jul 17, 2016
Also remove incorrect examples from the documentation of this method.

Fixes antlr#113
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants