Search in sources :

Example 1 with FileLoader

use of com.mitchellbosecke.pebble.loader.FileLoader in project symja_android_library by axkr.

the class TemplateUtils method getNewEngine.

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;
}
Also used : PebbleException(com.mitchellbosecke.pebble.error.PebbleException) ClasspathLoader(com.mitchellbosecke.pebble.loader.ClasspathLoader) ArrayList(java.util.ArrayList) Loader(com.mitchellbosecke.pebble.loader.Loader) DelegatingLoader(com.mitchellbosecke.pebble.loader.DelegatingLoader) ClasspathLoader(com.mitchellbosecke.pebble.loader.ClasspathLoader) FileLoader(com.mitchellbosecke.pebble.loader.FileLoader) FileLoader(com.mitchellbosecke.pebble.loader.FileLoader) DelegatingLoader(com.mitchellbosecke.pebble.loader.DelegatingLoader) PebbleEngine(com.mitchellbosecke.pebble.PebbleEngine)

Aggregations

PebbleEngine (com.mitchellbosecke.pebble.PebbleEngine)1 PebbleException (com.mitchellbosecke.pebble.error.PebbleException)1 ClasspathLoader (com.mitchellbosecke.pebble.loader.ClasspathLoader)1 DelegatingLoader (com.mitchellbosecke.pebble.loader.DelegatingLoader)1 FileLoader (com.mitchellbosecke.pebble.loader.FileLoader)1 Loader (com.mitchellbosecke.pebble.loader.Loader)1 ArrayList (java.util.ArrayList)1