com.mitchellbosecke.pebble.loader.Loader Java Examples
The following examples show how to use
com.mitchellbosecke.pebble.loader.Loader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TemplateUtils.java From tablesaw with Apache License 2.0 | 6 votes |
public static PebbleEngine getNewEngine() { PebbleEngine engine; try { Loader<?> loader = new ClasspathLoader(); if (templateLocations != null && !templateLocations.isEmpty()) { List<Loader<?>> loaders = new ArrayList<>(); for (String templateLocation : templateLocations) { FileLoader fileLoader = new FileLoader(); fileLoader.setPrefix(templateLocation); loaders.add(fileLoader); } // add this one last, so it is shadowed loaders.add(loader); loader = new DelegatingLoader(loaders); } engine = new PebbleEngine.Builder().loader(loader).strictVariables(false).build(); } catch (PebbleException e) { throw new IllegalStateException(e); } return engine; }
Example #2
Source File: TemplateUtils.java From tablesaw with Apache License 2.0 | 6 votes |
public static PebbleEngine getNewEngine() { PebbleEngine engine; try { Loader<?> loader = new ClasspathLoader(); if (templateLocations != null && !templateLocations.isEmpty()) { List<Loader<?>> loaders = new ArrayList<>(); for (String templateLocation : templateLocations) { FileLoader fileLoader = new FileLoader(); fileLoader.setPrefix(templateLocation); loaders.add(fileLoader); } // add this one last, so it is shadowed loaders.add(loader); loader = new DelegatingLoader(loaders); } engine = new PebbleEngine.Builder().loader(loader).strictVariables(false).build(); } catch (PebbleException e) { throw new IllegalStateException(e); } return engine; }
Example #3
Source File: PebbleTemplateEngine.java From pippo with Apache License 2.0 | 5 votes |
@Override public void init(Application application) { super.init(application); Router router = getRouter(); PippoSettings pippoSettings = getPippoSettings(); List<Loader<?>> loaders = new ArrayList<>(); PippoTemplateLoader templateLoader = new PippoTemplateLoader(); templateLoader.setCharset(PippoConstants.UTF8); templateLoader.setPrefix(getTemplatePathPrefix()); templateLoader.setSuffix("." + getFileExtension()); loaders.add(templateLoader); PebbleEngine.Builder builder = new PebbleEngine.Builder() .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())); if (pippoSettings.isDev()) { // do not cache templates in dev mode builder.cacheActive(false); builder.extension(new DebugExtension()); } // allow custom initialization init(application, builder); engine = builder.build(); }
Example #4
Source File: PebbleTemplateEngine.java From jbake with MIT License | 5 votes |
private void initializeTemplateEngine() { Loader loader = new FileLoader(); loader.setPrefix(config.getTemplateFolder().getAbsolutePath()); /* * Turn off the autoescaper because I believe that we can assume all * data is safe considering it is all statically generated. */ EscaperExtension escaper = new EscaperExtension(); escaper.setAutoEscaping(false); engine = new PebbleEngine.Builder().loader(loader).extension(escaper).build(); }
Example #5
Source File: PebbleTemplateEngine.java From spark-template-engines with Apache License 2.0 | 4 votes |
/** * Construct a new template engine using pebble with an engine using a special loader. */ public PebbleTemplateEngine(Loader loader) { this.engine = new PebbleEngine.Builder().loader(loader).build(); }