AngelDoReMi / closure-templates

Automatically exported from code.google.com/p/closure-templates
Apache License 2.0
0 stars 0 forks source link

Example uses deprecated function #41

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Visit http://code.google.com/closure/templates/docs/helloworld_java.html

The line:
System.out.println(tofu.render("examples.simple.helloWorld", (SoyMapData) null, 
null));

Should be updated to:
System.out.println(tofu.newRenderer("examples.simple.helloWorld").render());

Original issue reported on code.google.com by bmcc...@google.com on 29 Aug 2011 at 2:01

GoogleCodeExporter commented 8 years ago
Similarly, there are other lines that need to be updated.

System.out.println(simpleTofu.render(".helloName", new SoyMapData("name", 
"Ana"), null));

Should be:
    System.out.println(simpleTofu.newRenderer(".helloName")
        .setData(new SoyMapData("name", "Ana"))
        .render());

    System.out.println(
        simpleTofu.render(".helloNames",
            new SoyMapData("name", "Ana",
                           "additionalNames", new SoyListData("Bob", "Cid", "Dee")),
            null));

Should be:
    System.out.println(
        simpleTofu.newRenderer(".helloNames")
            .setData(new SoyMapData("name", "Ana",
                "additionalNames", new SoyListData("Bob", "Cid", "Dee")))
        .render());

Original comment by bmcc...@google.com on 29 Aug 2011 at 2:07

GoogleCodeExporter commented 8 years ago
Might also be worth mentioning that the following is also valid:

    System.out.println(simpleTofu.newRenderer(".helloName")
        .setData(ImmutableMap.of("name", "Ana"))
        .render());

    System.out.println(
        simpleTofu.newRenderer(".helloNames")
            .setData(ImmutableMap.of("name", "Ana",
                "additionalNames", ImmutableList.of("Bob", "Cid", "Dee")))
        .render());

Original comment by bmcc...@google.com on 29 Aug 2011 at 2:17

GoogleCodeExporter commented 8 years ago
Oops, take it back.  Turns out the newRenderer syntax is available only 
internally.  Maybe it's time for a new release?

Original comment by bmcc...@google.com on 29 Aug 2011 at 2:42

GoogleCodeExporter commented 8 years ago

Original comment by kai.hu...@gmail.com on 20 Sep 2011 at 12:09