Search in sources :

Example 1 with PebbleVertxLoader

use of io.vertx.ext.web.templ.pebble.impl.PebbleVertxLoader in project vertx-web by vert-x3.

the class PebbleTemplateTest method customBuilderShouldRender.

@Test
public void customBuilderShouldRender() throws Exception {
    final TemplateEngine engine = PebbleTemplateEngine.create(new PebbleEngine.Builder().extension(new TestExtension()).loader(new PebbleVertxLoader(vertx)).build());
    testTemplateHandler(engine, "src/test/filesystemtemplates", "test-pebble-template5.peb", "Hello badger and foxString is TESTRequest path is /test-pebble-template5.peb");
}
Also used : PebbleTemplateEngine(io.vertx.ext.web.templ.pebble.PebbleTemplateEngine) PebbleVertxLoader(io.vertx.ext.web.templ.pebble.impl.PebbleVertxLoader) TestExtension(io.vertx.ext.web.templ.extension.TestExtension) Test(org.junit.Test)

Example 2 with PebbleVertxLoader

use of io.vertx.ext.web.templ.pebble.impl.PebbleVertxLoader in project vertx-web by vert-x3.

the class PebbleTemplateTest method customBuilderShouldRender.

@Test
public void customBuilderShouldRender(TestContext should) {
    final TemplateEngine engine = PebbleTemplateEngine.create(vertx, new PebbleEngine.Builder().extension(new TestExtension()).loader(new PebbleVertxLoader(vertx)).build());
    final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox").put("context", new JsonObject().put("path", "/test-pebble-template5.peb"));
    engine.render(context, "src/test/filesystemtemplates/test-pebble-template5.peb", should.asyncAssertSuccess(render -> {
        should.assertEquals("Hello badger and foxString is TESTRequest path is /test-pebble-template5.peb", normalizeCRLF(render.toString()));
    }));
}
Also used : TestContext(io.vertx.ext.unit.TestContext) PrintWriter(java.io.PrintWriter) BeforeClass(org.junit.BeforeClass) FileSystemOptions(io.vertx.core.file.FileSystemOptions) PebbleTemplateEngine(io.vertx.ext.web.templ.pebble.PebbleTemplateEngine) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) Vertx(io.vertx.core.Vertx) RunWith(org.junit.runner.RunWith) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test) IOException(java.io.IOException) HashMap(java.util.HashMap) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) File(java.io.File) ArrayList(java.util.ArrayList) TestExtension(io.vertx.ext.web.templ.extension.TestExtension) JsonArray(io.vertx.core.json.JsonArray) PebbleVertxLoader(io.vertx.ext.web.templ.pebble.impl.PebbleVertxLoader) PebbleEngine(com.mitchellbosecke.pebble.PebbleEngine) Locale(java.util.Locale) JsonObject(io.vertx.core.json.JsonObject) PebbleTemplateEngine(io.vertx.ext.web.templ.pebble.PebbleTemplateEngine) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) PebbleVertxLoader(io.vertx.ext.web.templ.pebble.impl.PebbleVertxLoader) JsonObject(io.vertx.core.json.JsonObject) TestExtension(io.vertx.ext.web.templ.extension.TestExtension) Test(org.junit.Test)

Aggregations

TestExtension (io.vertx.ext.web.templ.extension.TestExtension)2 PebbleTemplateEngine (io.vertx.ext.web.templ.pebble.PebbleTemplateEngine)2 PebbleVertxLoader (io.vertx.ext.web.templ.pebble.impl.PebbleVertxLoader)2 Test (org.junit.Test)2 PebbleEngine (com.mitchellbosecke.pebble.PebbleEngine)1 Vertx (io.vertx.core.Vertx)1 VertxOptions (io.vertx.core.VertxOptions)1 FileSystemOptions (io.vertx.core.file.FileSystemOptions)1 JsonArray (io.vertx.core.json.JsonArray)1 JsonObject (io.vertx.core.json.JsonObject)1 TestContext (io.vertx.ext.unit.TestContext)1 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)1 TemplateEngine (io.vertx.ext.web.common.template.TemplateEngine)1 File (java.io.File)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 BeforeClass (org.junit.BeforeClass)1