Пример #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));
 }