Search in sources :

Example 1 with HandlebarsTemplateEngine

use of io.vertx.ext.web.templ.handlebars.HandlebarsTemplateEngine in project vertx-web by vert-x3.

the class HandlebarsTemplateTest method testCustomResolver.

@Test
public void testCustomResolver() throws Exception {
    HandlebarsTemplateEngine engine = HandlebarsTemplateEngine.create();
    engine.setResolvers(new ValueResolver() {

        @Override
        public Object resolve(Object context, String name) {
            return "custom";
        }

        @Override
        public Object resolve(Object context) {
            return "custom";
        }

        @Override
        public Set<Entry<String, Object>> propertySet(Object context) {
            return Collections.emptySet();
        }
    });
    testTemplateHandlerWithContext(engine, "src/test/filesystemtemplates", "test-handlebars-template3.hbs", "Goodbye custom and custom", context -> {
        context.put("foo", "Badger");
        context.put("bar", "Fox");
        context.next();
    });
}
Also used : Set(java.util.Set) ValueResolver(com.github.jknack.handlebars.ValueResolver) JsonObject(io.vertx.core.json.JsonObject) HandlebarsTemplateEngine(io.vertx.ext.web.templ.handlebars.HandlebarsTemplateEngine) Test(org.junit.Test)

Example 2 with HandlebarsTemplateEngine

use of io.vertx.ext.web.templ.handlebars.HandlebarsTemplateEngine in project vertx-web by vert-x3.

the class HandlebarsTemplateTest method testGetHandlebars.

@Test
public void testGetHandlebars() throws Exception {
    HandlebarsTemplateEngine engine = HandlebarsTemplateEngine.create();
    assertNotNull(engine.getHandlebars());
}
Also used : HandlebarsTemplateEngine(io.vertx.ext.web.templ.handlebars.HandlebarsTemplateEngine) Test(org.junit.Test)

Aggregations

HandlebarsTemplateEngine (io.vertx.ext.web.templ.handlebars.HandlebarsTemplateEngine)2 Test (org.junit.Test)2 ValueResolver (com.github.jknack.handlebars.ValueResolver)1 JsonObject (io.vertx.core.json.JsonObject)1 Set (java.util.Set)1