use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class RockerTemplateEngineTest method testTemplateHandlerIncludes.
@Test
public void testTemplateHandlerIncludes(TestContext should) {
TemplateEngine engine = RockerTemplateEngine.create();
final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox").put("context", new JsonObject().put("path", "/TestRockerTemplate3"));
engine.render(context, "somedir/Base", should.asyncAssertSuccess(render -> {
should.assertEquals("Vert.x rules\n", normalizeCRLF(render.toString()));
}));
}
use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class RockerTemplateEngineTest method testTemplateHandler.
@Test
public void testTemplateHandler(TestContext should) {
TemplateEngine engine = RockerTemplateEngine.create();
final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox").put("context", new JsonObject().put("path", "/TestRockerTemplate2.rocker.html"));
engine.render(context, "somedir/TestRockerTemplate2.rocker.html", should.asyncAssertSuccess(render -> {
should.assertEquals("Hello badger and fox\nRequest path is /TestRockerTemplate2.rocker.html\n", normalizeCRLF(render.toString()));
}));
}
use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class RythmTemplateTest method testWithLocale.
@Test
public void testWithLocale(TestContext should) {
TemplateEngine engine = RythmTemplateEngine.create(vertx);
final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox").put("lang", "en-gb");
engine.render(context, "somedir/test-rythm-template2.html", should.asyncAssertSuccess(render -> {
final String expected = "<!DOCTYPE html>\n" + "<html lang=\"en\">\n" + "<head>\n" + "<meta charset=\"UTF-8\">\n" + "<title>Title</title>\n" + "</head>\n" + "<body>\n" + "<p>badger</p>\n" + "<p>fox</p>\n" + "</body>\n" + "</html>\n";
should.assertEquals(expected, normalizeCRLF(render.toString()));
}));
}
use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class RythmTemplateTest method testTemplateHandlerOnFileSystem.
@Test
public void testTemplateHandlerOnFileSystem(TestContext should) {
TemplateEngine engine = RythmTemplateEngine.create(vertx);
final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox");
engine.render(context, "src/test/filesystemtemplates/test-rythm-template.html", should.asyncAssertSuccess(render -> {
final String expected = "<!DOCTYPE html>\n" + "<html lang=\"en\">\n" + "<head>\n" + "<meta charset=\"UTF-8\">\n" + "<title>FS</title>\n" + "</head>\n" + "<body>\n" + "<p>badger</p>\n" + "<p>fox</p>\n" + "</body>\n" + "</html>\n";
should.assertEquals(expected, normalizeCRLF(render.toString()));
}));
}
use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class ThymeleafTemplateTest method testWithLocale.
@Test
public void testWithLocale(TestContext should) {
TemplateEngine engine = ThymeleafTemplateEngine.create(vertx);
final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox").put("lang", "en-gb").put("context", new JsonObject().put("path", "/test-thymeleaf-template2.html"));
engine.render(context, "somedir/test-thymeleaf-template2.html", should.asyncAssertSuccess(render -> {
final String expected = "<!doctype html>\n" + "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + "<head>\n" + " <meta charset=\"utf-8\">\n" + "</head>\n" + "<body>\n" + "<p>badger</p>\n" + "<p>fox</p>\n" + "<p>/test-thymeleaf-template2.html</p>\n" + "</body>\n" + "</html>\n";
should.assertEquals(expected, normalizeCRLF(render.toString()));
}));
}
Aggregations