use of com.google.template.soy.data.SoyMapData in project closure-templates by google.
the class SimpleUsage method main.
/**
* Prints the generated HTML to stdout.
*
* @param args Not used.
*/
public static void main(String[] args) {
// Compile the template.
SoyFileSet sfs = SoyFileSet.builder().add(Resources.getResource("simple.soy")).build();
SoyTofu tofu = sfs.compileToTofu();
// Example 1.
writeExampleHeader();
System.out.println(tofu.newRenderer("soy.examples.simple.helloWorld").render());
// Create a namespaced tofu object to make calls more concise.
SoyTofu simpleTofu = tofu.forNamespace("soy.examples.simple");
// Example 2.
writeExampleHeader();
System.out.println(simpleTofu.newRenderer(".helloName").setData(new SoyMapData("name", "Ana")).render());
// Example 3.
writeExampleHeader();
System.out.println(simpleTofu.newRenderer(".helloNames").setData(new SoyMapData("names", new SoyListData("Bob", "Cid", "Dee"))).render());
}
use of com.google.template.soy.data.SoyMapData in project gitiles by GerritCodeReview.
the class HostIndexServletTest method rootHtml.
@Test
public void rootHtml() throws Exception {
Map<String, ?> data = buildData("/");
assertThat(data).containsEntry("hostName", URLS.getHostName(null));
assertThat(data).containsEntry("breadcrumbs", NullData.INSTANCE);
assertThat(data).containsEntry("prefix", "");
SoyListData repos = (SoyListData) data.get("repositories");
assertThat(repos).hasSize(1);
SoyMapData ent = (SoyMapData) repos.get(0);
assertThat(ent.get("name").toString()).isEqualTo(NAME);
assertThat(ent.get("url").toString()).isEqualTo("/b/" + NAME + "/");
}
Aggregations