コード例 #1
0
 @Test
 public void list() throws IOException {
   Handlebars handlebars = new Handlebars();
   Template template =
       handlebars.compile("{{#" + selector + "}}{{" + selector + "}} {{/" + selector + "}}");
   assertEquals("1 2 3 ", template.apply(new Object[] {1, 2, 3}));
 }
コード例 #2
0
 @Test
 public void decimal() throws IOException {
   Handlebars handlebars = new Handlebars();
   Template template = handlebars.compile("var d = {{" + selector + "}};");
   assertEquals("var d = 1.34;", template.apply(1.34));
 }
コード例 #3
0
 @Test
 public void bool() throws IOException {
   Handlebars handlebars = new Handlebars();
   Template template = handlebars.compile("if ({{" + selector + "}})");
   assertEquals("if (true)", template.apply(true));
 }
コード例 #4
0
 @Test
 public void htmlString() throws IOException {
   Handlebars handlebars = new Handlebars();
   Template template = handlebars.compile("var s = '{{" + selector + "}}';");
   assertEquals("var s = '&lt;div&gt;';", template.apply("<div>"));
 }
コード例 #5
0
 @Test
 public void chHtml() throws IOException {
   Handlebars handlebars = new Handlebars();
   Template template = handlebars.compile("var s = '{{" + selector + "}}';");
   assertEquals("var s = '&lt;';", template.apply('<'));
 }
コード例 #6
0
 @Test
 public void safeString() throws IOException {
   Handlebars handlebars = new Handlebars();
   Template template = handlebars.compile("var s = '{{" + selector + "}}';");
   assertEquals("var s = '<div>';", template.apply(new Handlebars.SafeString("<div>")));
 }
コード例 #7
0
 @Test
 public void string() throws IOException {
   Handlebars handlebars = new Handlebars();
   Template template = handlebars.compile("var s = '{{" + selector + "}}';");
   assertEquals("var s = 'Hello';", template.apply("Hello"));
 }
コード例 #8
0
 @Test
 public void integer() throws IOException {
   Handlebars handlebars = new Handlebars();
   Template template = handlebars.compile("var i = {{" + selector + "}};");
   assertEquals("var i = 10;", template.apply(10));
 }