use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class MVELTemplateTest method testTemplateHandlerChangeExtension.
@Test
public void testTemplateHandlerChangeExtension(TestContext should) {
TemplateEngine engine = MVELTemplateEngine.create(vertx, "bempl");
final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox");
context.put("context", new JsonObject().put("path", "/test-mvel-template2"));
String tmplPath = "somedir/test-mvel-template2".replace('/', File.separatorChar);
engine.render(context, tmplPath, should.asyncAssertSuccess(render -> {
should.assertEquals("Cheerio badger and fox\nRequest path is /test-mvel-template2\n", normalizeCRLF(render.toString()));
}));
}
use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class MVELTemplateTest method testTemplateHandlerNoExtension.
@Test
public void testTemplateHandlerNoExtension(TestContext should) {
TemplateEngine engine = MVELTemplateEngine.create(vertx);
final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox");
context.put("context", new JsonObject().put("path", "/test-mvel-template2.templ"));
String tmplPath = "somedir/test-mvel-template2".replace('/', File.separatorChar);
engine.render(context, tmplPath, should.asyncAssertSuccess(render -> {
should.assertEquals("Hello badger and fox\nRequest path is /test-mvel-template2.templ\n", normalizeCRLF(render.toString()));
}));
}
use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class MVELTemplateTest method testTemplateHandlerWithInclude.
@Test
public void testTemplateHandlerWithInclude(TestContext should) {
// Cannot pass on windows due to
// File file = new File(runtime.getRelPath().peek() + "/" + fileName);
// in org.mvel2.templates.res.CompiledIncludeNode
Assume.assumeFalse(Utils.isWindows());
TemplateEngine engine = MVELTemplateEngine.create(vertx);
final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox");
context.put("context", new JsonObject().put("path", "/test-mvel-template4.templ"));
String tmplPath = "src/test/filesystemtemplates/test-mvel-template4.templ".replace('/', File.separatorChar);
engine.render(context, tmplPath, should.asyncAssertSuccess(render -> {
should.assertEquals("Hello badger and fox\n\nRequest path is /test-mvel-template4.templ\n", normalizeCRLF(render.toString()));
}));
}
use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class PebbleTemplateTest method testTemplateHandlerChangeExtension.
@Test
public void testTemplateHandlerChangeExtension(TestContext should) {
TemplateEngine engine = PebbleTemplateEngine.create(vertx, "beb");
final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox").put("context", new JsonObject().put("path", "/test-pebble-template2.peb"));
engine.render(context, "somedir/test-pebble-template2", should.asyncAssertSuccess(render -> {
should.assertEquals("Cheerio badger and foxRequest path is /test-pebble-template2.peb", normalizeCRLF(render.toString()));
}));
}
use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class PebbleTemplateTest method testTemplateComplex.
@Test
public void testTemplateComplex(TestContext should) {
TemplateEngine engine = PebbleTemplateEngine.create(vertx);
String expected = "Hello.Hi fox.\nHi badger!\nFooter - badger";
final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox");
engine.render(context, "src/test/filesystemtemplates/test-pebble-complex.peb", should.asyncAssertSuccess(render -> {
should.assertEquals(expected, normalizeCRLF(render.toString()));
}));
}
Aggregations