callback.accept(pebble, conf); this.pebble.extension(new XssExt(env)); PebbleEngine pebble = this.pebble.build(); binder.bind(PebbleEngine.class).toInstance(pebble);
@Bean public PebbleEngine pebbleEngine() { PebbleEngine.Builder builder = new PebbleEngine.Builder(); builder.loader(this.pebbleLoader); builder.extension(this.pebbleSpringExtension()); if (this.extensions != null && !this.extensions.isEmpty()) { builder.extension(this.extensions.toArray(new Extension[this.extensions.size()])); } if (!this.properties.isCache()) { builder.cacheActive(false); } if (this.properties.getDefaultLocale() != null) { builder.defaultLocale(this.properties.getDefaultLocale()); } builder.strictVariables(this.properties.isStrictVariables()); builder.greedyMatchMethod(this.properties.isGreedyMatchMethod()); return builder.build(); } }
@Bean public PebbleEngine pebbleEngine() { PebbleEngine.Builder builder = new PebbleEngine.Builder(); builder.loader(this.pebbleLoader); builder.extension(this.pebbleSpringExtension()); if (this.extensions != null && !this.extensions.isEmpty()) { builder.extension(this.extensions.toArray(new Extension[this.extensions.size()])); } if (!this.properties.isCache()) { builder.cacheActive(false); } if (this.properties.getDefaultLocale() != null) { builder.defaultLocale(this.properties.getDefaultLocale()); } builder.strictVariables(this.properties.isStrictVariables()); builder.greedyMatchMethod(this.properties.isGreedyMatchMethod()); return builder.build(); } }
callback.accept(pebble, conf); this.pebble.extension(new XssExt(env)); PebbleEngine pebble = this.pebble.build(); binder.bind(PebbleEngine.class).toInstance(pebble);
@Bean public PebbleEngine pebbleEngine() { PebbleEngine.Builder builder = new PebbleEngine.Builder(); builder.loader(this.pebbleLoader); builder.extension(this.pebbleSpringExtension()); if (this.extensions != null && !this.extensions.isEmpty()) { builder.extension(this.extensions.toArray(new Extension[this.extensions.size()])); } if (!this.properties.isCache()) { builder.cacheActive(false); } if (this.properties.getDefaultLocale() != null) { builder.defaultLocale(this.properties.getDefaultLocale()); } builder.strictVariables(this.properties.isStrictVariables()); return builder.build(); } }
@Test public void customBuilderShouldRender(TestContext should) { final Async test = should.async(); final TemplateEngine engine = PebbleTemplateEngine.create(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", render -> { should.assertTrue(render.succeeded()); should.assertEquals("Hello badger and foxString is TESTRequest path is /test-pebble-template5.peb", render.result().toString()); test.complete(); }); }
.loader(new DelegatingLoader(loaders)) .strictVariables(false) .extension(new GlobalVariablesExtension() .set("contextPath", router.getContextPath()) .set("appPath", router.getApplicationPath())) .extension(new I18nExtension(application.getMessages())) .extension(new FormatTimeExtension()) .extension(new PrettyTimeExtension()) .extension(new AngularJSExtension()) .extension(new WebjarsAtExtension(router)) .extension(new PublicAtExtension(router)) .extension(new RouteExtension(application.getRouter())); builder.extension(new DebugExtension());