Java Code Examples for com.github.jknack.handlebars.Handlebars

The following examples show how to use com.github.jknack.handlebars.Handlebars. These examples are extracted from open source projects. 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 Project: product-microgateway   Author: wso2   File: CodegenUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Compile given template.
 *
 * @param defaultTemplateDir template directory
 * @param templateName template name
 * @return Generated template
 * @throws IOException if file read went wrong
 */
public static Template compileTemplate(String defaultTemplateDir, String templateName) throws IOException {
    String templatesDirPath = System.getProperty(GeneratorConstants.TEMPLATES_DIR_PATH_KEY, defaultTemplateDir);
    ClassPathTemplateLoader cpTemplateLoader = new ClassPathTemplateLoader((templatesDirPath));
    FileTemplateLoader fileTemplateLoader = new FileTemplateLoader(templatesDirPath);
    cpTemplateLoader.setSuffix(GeneratorConstants.TEMPLATES_SUFFIX);
    fileTemplateLoader.setSuffix(GeneratorConstants.TEMPLATES_SUFFIX);

    Handlebars handlebars = new Handlebars().with(cpTemplateLoader, fileTemplateLoader);
    handlebars.setStringParams(true);
    handlebars.registerHelpers(StringHelpers.class);
    handlebars.registerHelper("equals", (object, options) -> {
        Object param0 = options.param(0, null);

        if (param0 == null) {
            throw new IllegalArgumentException("found 'null', expected 'string'");
        }
        if (object != null && object.toString().equals(param0.toString())) {
                return options.fn(options.context);
        }

        return options.inverse();
    });

    return handlebars.compile(templateName);
}
 
Example #2
Source Project: sling-samples   Author: apache   File: HandlebarsScriptEngine.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Object eval(String script, ScriptContext context) throws ScriptException {
    final Resource resource = (Resource) context.getBindings(ScriptContext.ENGINE_SCOPE).get(SlingBindings.RESOURCE);
    final PrintWriter out = (PrintWriter) context.getBindings(ScriptContext.ENGINE_SCOPE).get(SlingBindings.OUT);

    try {
        final Handlebars handlebars = setupHandlebars();
        final Template template = handlebars.compileInline(script);
        out.println(template.apply(getData(resource)));
    } catch(IOException ioe) {
        final ScriptException up = new ScriptException("IOException in eval");
        up.initCause(ioe);
        throw up;
    }
    return null;
}
 
Example #3
Source Project: tutorials   Author: eugenp   File: ReusingTemplatesUnitTest.java    License: MIT License 6 votes vote down vote up
@Test
public void whenBlockIsDefined_ThenCanOverrideWithPartial() throws IOException {
    Handlebars handlebars = new Handlebars(templateLoader);
    Template template = handlebars.compile("simplemessage");
    Person person = new Person();
    person.setName("Baeldung");

    String templateString = template.apply(person);

    assertThat(templateString).contains("<html>",
      "<body>",
      "This is the intro",
      "Hi there!",
      "</body>",
      "</html>");
}
 
Example #4
Source Project: bootstraped-multi-test-results-report   Author: web-innovate   File: RSpecReportBuilder.java    License: MIT License 6 votes vote down vote up
private void writeTestsPassedReport() throws IOException {
    Template template = new Helpers(new Handlebars()).registerHelpers().compile(TEST_OVERVIEW_REPORT);

    List<TestSuiteModel> onlyPassed = new ArrayList<>(processedTestSuites);

    for (Iterator<TestSuiteModel> it = onlyPassed.listIterator(); it.hasNext(); ) {
        TestSuiteModel f = it.next();
        if (f.getOverallStatus().equalsIgnoreCase(Constants.FAILED)) {
            it.remove();
        }
    }

    AllRSpecJUnitReports allTestSuites = new AllRSpecJUnitReports("Passed test suites report", onlyPassed);
    FileUtils.writeStringToFile(new File(TEST_OVERVIEW_PATH + "testsPassed.html"),
        template.apply(allTestSuites));
}
 
Example #5
Source Project: Singularity   Author: HubSpot   File: SingularityExecutorModule.java    License: Apache License 2.0 6 votes vote down vote up
@Provides
@Singleton
public Handlebars providesHandlebars() {
  SingularityRunnerBaseLogging.quietEagerLogging(); // handlebars emits DEBUG logs before logger is properly configured
  final Handlebars handlebars = new Handlebars();

  handlebars.registerHelper(BashEscapedHelper.NAME, new BashEscapedHelper());
  handlebars.registerHelper(ShellQuoteHelper.NAME, new ShellQuoteHelper());
  handlebars.registerHelper(IfPresentHelper.NAME, new IfPresentHelper());
  handlebars.registerHelper(
    IfHasNewLinesOrBackticksHelper.NAME,
    new IfHasNewLinesOrBackticksHelper()
  );
  handlebars.registerHelper(
    EscapeNewLinesAndQuotesHelper.NAME,
    new EscapeNewLinesAndQuotesHelper()
  );

  return handlebars;
}
 
Example #6
Source Project: commercetools-sunrise-java   Author: commercetools   File: HandlebarsFactory.java    License: Apache License 2.0 6 votes vote down vote up
static Handlebars create(final List<TemplateLoader> templateLoaders, final I18nResolver i18NResolver, final I18nIdentifierFactory i18nIdentifierFactory) {
    if (templateLoaders.isEmpty()) {
        throw new SunriseConfigurationException("Could not initialize Handlebars due to missing template loaders configuration", CONFIG_TEMPLATE_LOADERS);
    }
    logger.info("Provide Handlebars: template loaders [{}]]",
            templateLoaders.stream().map(TemplateLoader::getPrefix).collect(joining(", ")));
    final TemplateLoader[] loaders = templateLoaders.toArray(new TemplateLoader[templateLoaders.size()]);
    final Handlebars handlebars = new Handlebars()
            .with(loaders)
            .with(new HighConcurrencyTemplateCache())
            .infiniteLoops(true);
    handlebars.registerHelper("i18n", new HandlebarsI18nHelper(i18NResolver, i18nIdentifierFactory));
    handlebars.registerHelper("cms", new HandlebarsCmsHelper());
    handlebars.registerHelper("json", new HandlebarsJsonHelper<>());
    return handlebars;
}
 
Example #7
Source Project: arcusplatform   Author: arcus-smart-home   File: TestTemplatesCompile.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testTemplatesCompile() throws Exception {
   TemplateLoader loader = new IrisResourceLoader("templates", 0);
   Handlebars handlebars = 
         new Handlebars(loader)
            .registerHelper(EnumHelper.NAME, EnumHelper.INSTANCE)
            .registerHelpers(HandlebarsHelpersSource.class)
            .registerHelper(IfEqualHelper.NAME, IfEqualHelper.INSTANCE)
            .registerHelpers(StringHelpers.class);
   Validator v = new Validator();
   String templateDir =
         Resources
            .getResource("templates")
            .getUri()
            .toURL()
            .getPath();
   for(File template: new File(templateDir).listFiles((file) -> file != null && file.getName() != null && file.getName().endsWith(".hbs"))) {
      try {
         String name = template.getName();
         name = name.substring(0, name.length() - 4);
         Template tpl = handlebars.compile(name);
         if(name.endsWith("-email")) {
            // TODO validate email xml
            continue;
         }
         
         String body  = tpl.apply(Context.newContext(Collections.emptyMap()));
         JSON.fromJson(body, Map.class);
      }
      catch(Exception e) {
         e.printStackTrace();
         v.error("Failed to compile: " + template.getName() + " -- " + e.getMessage());
      }
   }
   v.throwIfErrors();
}
 
Example #8
Source Project: arcusplatform   Author: arcus-smart-home   File: TestMessages.java    License: Apache License 2.0 5 votes vote down vote up
public Templater() {
	templates.put(MSG_KEY_THING + "-apns", TEMPLATE_THING);
	templates.put(MSG_KEY_ENUM + "-apns", TEMPLATE_ENUM);
	handlebars = new Handlebars()
		.registerHelper(EnumHelper.NAME, EnumHelper.INSTANCE)
		.registerHelpers(HandlebarsHelpersSource.class)
		.registerHelpers(StringHelpers.class);
}
 
Example #9
Source Project: arcusplatform   Author: arcus-smart-home   File: HandlebarsTemplateService.java    License: Apache License 2.0 5 votes vote down vote up
private void init(String prefix, int cacheSize){
	LOGGER.info("Handlebars Template Service Initialization with a location of {} and cache size of {}",prefix,cacheSize);
	templateCache = new ConcurrentMapTemplateCache();		
	
	TemplateLoader loader=new IrisResourceLoader(prefix, cacheSize);
	handlebars=new Handlebars(loader)
		.with(templateCache)
		.registerHelper(EnumHelper.NAME, EnumHelper.INSTANCE)
		.registerHelper(IfEqualHelper.NAME, IfEqualHelper.INSTANCE)
		.registerHelpers(HandlebarsHelpersSource.class)
		.registerHelpers(StringHelpers.class)
		.registerHelper(PluralizeHelper.NAME, PluralizeHelper.INSTANCE);
}
 
Example #10
Source Project: openapi-generator   Author: OpenAPITools   File: HandlebarsEngineAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public String compileTemplate(TemplatingExecutor executor,
                              Map<String, Object> bundle, String templateFile) throws IOException {
    TemplateLoader loader = new AbstractTemplateLoader() {
        @Override
        public TemplateSource sourceAt(String location) {
            return findTemplate(executor, location);
        }
    };

    Context context = Context
            .newBuilder(bundle)
            .resolver(
                    MapValueResolver.INSTANCE,
                    JavaBeanValueResolver.INSTANCE,
                    FieldValueResolver.INSTANCE)
            .build();

    Handlebars handlebars = new Handlebars(loader);
    handlebars.registerHelperMissing((obj, options) -> {
        LOGGER.warn(String.format(Locale.ROOT, "Unregistered helper name '%s', processing template:\n%s", options.helperName, options.fn.text()));
        return "";
    });
    handlebars.registerHelper("json", Jackson2Helper.INSTANCE);
    StringHelpers.register(handlebars);
    handlebars.registerHelpers(ConditionalHelpers.class);
    handlebars.registerHelpers(org.openapitools.codegen.templating.handlebars.StringHelpers.class);
    Template tmpl = handlebars.compile(templateFile);
    return tmpl.apply(context);
}
 
Example #11
Source Project: tutorials   Author: eugenp   File: BuiltinHelperUnitTest.java    License: MIT License 5 votes vote down vote up
@Test
public void whenUsedWithMustacheStyle_ThenContextChanges() throws IOException {
    Handlebars handlebars = new Handlebars(templateLoader);
    Template template = handlebars.compile("with_mustache");
    Person person = getPerson("Baeldung");
    person.getAddress().setStreet("World");

    String templateString = template.apply(person);

    assertThat(templateString).contains("<h4>I live in World</h4>");
}
 
Example #12
Source Project: Baragon   Author: HubSpot   File: BaragonAgentServiceModule.java    License: Apache License 2.0 5 votes vote down vote up
@Provides
@Singleton
@Named(AGENT_TEMPLATES)
public Map<String, List<LbConfigTemplate>> providesAgentTemplates(Handlebars handlebars, BaragonAgentConfiguration configuration) throws Exception {
  Map<String, List<LbConfigTemplate>> templates = new HashMap<>();

  for (TemplateConfiguration templateConfiguration : configuration.getTemplates()) {
    if (!Strings.isNullOrEmpty(templateConfiguration.getDefaultTemplate())) {
      if (templates.containsKey(DEFAULT_TEMPLATE_NAME)) {
        templates.get(DEFAULT_TEMPLATE_NAME).add(new LbConfigTemplate(templateConfiguration.getFilename(), handlebars.compileInline(templateConfiguration.getDefaultTemplate()), getFilePathFormatType(templateConfiguration.getFilename())));
      } else {
        templates.put(DEFAULT_TEMPLATE_NAME, Lists.newArrayList(new LbConfigTemplate(templateConfiguration.getFilename(), handlebars.compileInline(templateConfiguration.getDefaultTemplate()), getFilePathFormatType(templateConfiguration.getFilename()))));
      }
    }
    if (templateConfiguration.getNamedTemplates() != null) {
      for (Map.Entry<String, String> entry : templateConfiguration.getNamedTemplates().entrySet()) {
        if (!Strings.isNullOrEmpty(entry.getValue())) {
          if (templates.containsKey(entry.getKey())) {
            templates.get(entry.getKey()).add(new LbConfigTemplate(templateConfiguration.getFilename(), handlebars.compileInline(entry.getValue()), getFilePathFormatType(templateConfiguration.getFilename())));
          } else {
            templates.put(entry.getKey(), Lists.newArrayList(new LbConfigTemplate(templateConfiguration.getFilename(), handlebars.compileInline(entry.getValue()), getFilePathFormatType(templateConfiguration.getFilename()))));
          }
        }
      }
    }
  }

  return templates;
}
 
Example #13
Source Project: tutorials   Author: eugenp   File: BasicUsageUnitTest.java    License: MIT License 5 votes vote down vote up
@Test
public void whenParameterObjectIsSupplied_ThenDisplays() throws IOException {
    Handlebars handlebars = new Handlebars();
    Template template = handlebars.compileInline("Hi {{name}}!");
    Person person = new Person();
    person.setName("Baeldung");

    String templateString = template.apply(person);

    assertThat(templateString).isEqualTo("Hi Baeldung!");
}
 
Example #14
Source Project: bootstraped-multi-test-results-report   Author: web-innovate   File: TestNgReportBuilder.java    License: MIT License 5 votes vote down vote up
private void writeTestsByClassOverview() throws IOException {
    Template template = new Helpers(new Handlebars()).registerHelpers().compile(testOverviewReport);
    AllTestNgReports allTestNgReports =
        new AllTestNgReports("Tests by class overview report", processedTestNgReports);
    FileUtils.writeStringToFile(new File(testOverviewPath + TESTS_BY_CLASS_OVERVIEW),
        template.apply(allTestNgReports));
}
 
Example #15
Source Project: tutorials   Author: eugenp   File: ReusingTemplatesUnitTest.java    License: MIT License 5 votes vote down vote up
@Test
public void whenOtherTemplateIsReferenced_ThenCanReuse() throws IOException {
    Handlebars handlebars = new Handlebars(templateLoader);
    Template template = handlebars.compile("page");
    Person person = new Person();
    person.setName("Baeldung");

    String templateString = template.apply(person);

    assertThat(templateString)
      .contains("<h4>Hi Baeldung!</h4>", "<p>This is the page Baeldung</p>");
}
 
Example #16
Source Project: tutorials   Author: eugenp   File: CustomHelperUnitTest.java    License: MIT License 5 votes vote down vote up
@Test
public void whenHelperSourceIsCreated_ThenCanRegister() throws IOException {
    Handlebars handlebars = new Handlebars(templateLoader);
    handlebars.registerHelpers(new HelperSource());
    Template template = handlebars.compile("person");
    Person person = getPerson("Baeldung");

    String templateString = template.apply(person);

    assertThat(templateString).isEqualTo("Baeldung - busy");
}
 
Example #17
Source Project: tutorials   Author: eugenp   File: BuiltinHelperUnitTest.java    License: MIT License 5 votes vote down vote up
@Test
public void whenUsedEachMustacheStyle_ThenIterates() throws IOException {
    Handlebars handlebars = new Handlebars(templateLoader);
    Template template = handlebars.compile("each_mustache");
    Person person = getPerson("Baeldung");
    Person friend1 = getPerson("Java");
    Person friend2 = getPerson("Spring");
    person.getFriends().add(friend1);
    person.getFriends().add(friend2);

    String templateString = template.apply(person);

    assertThat(templateString)
      .contains("<span>Java is my friend.</span>", "<span>Spring is my friend.</span>");
}
 
Example #18
Source Project: bootstraped-multi-test-results-report   Author: web-innovate   File: JUnitReportBuilder.java    License: MIT License 5 votes vote down vote up
private void writeTestCaseSummaryReport() throws IOException {
    Template template = new Helpers(new Handlebars()).registerHelpers().compile(TEST_SUMMARY_REPORT);
    for (TestSuiteModel ts : processedTestSuites) {
        String content = template.apply(ts);
        FileUtils.writeStringToFile(new File(TEST_SUMMARY_PATH + ts.getUniqueID() + ".html"),
            content);
    }
}
 
Example #19
Source Project: tutorials   Author: eugenp   File: BasicUsageUnitTest.java    License: MIT License 5 votes vote down vote up
@Test
public void whenMultipleLoadersAreGiven_ThenSearchesSequentially() throws IOException {
    TemplateLoader firstLoader = new ClassPathTemplateLoader("/handlebars", ".html");
    TemplateLoader secondLoader = new ClassPathTemplateLoader("/templates", ".html");
    Handlebars handlebars = new Handlebars().with(firstLoader, secondLoader);
    Template template = handlebars.compile("greeting");
    Person person = getPerson("Baeldung");

    String templateString = template.apply(person);

    assertThat(templateString).isEqualTo("Hi Baeldung!");
}
 
Example #20
Source Project: bootstraped-multi-test-results-report   Author: web-innovate   File: Helpers.java    License: MIT License 5 votes vote down vote up
public Handlebars registerHelpers() {
    handlebar.registerHelper("date", dateHelper());
    handlebar.registerHelper("embedding", embeddingHelper());
    handlebar.registerHelper("result-color", resultColorHelper());
    handlebar.registerHelper("resolve-title", resolveTitleHelper());
    handlebar.registerHelper("is-collapsed", isCollapsedHelper());
    handlebar.registerHelper("now", nowHelper());
    handlebar.registerHelper("do_table", doTableHelper());
    handlebar.registerHelper("do_table_step", doTableHelperForStep());
    return handlebar;
}
 
Example #21
Source Project: bootstraped-multi-test-results-report   Author: web-innovate   File: RSpecReportBuilder.java    License: MIT License 5 votes vote down vote up
private void writeTestCaseSummaryReport() throws IOException {
    Template template = new Helpers(new Handlebars()).registerHelpers().compile(TEST_SUMMARY_REPORT);
    for (TestSuiteModel ts : processedTestSuites) {
        String content = template.apply(ts);
        FileUtils.writeStringToFile(new File(TEST_SUMMARY_PATH + ts.getUniqueID() + ".html"),
            content);
    }
}
 
Example #22
Source Project: tutorials   Author: eugenp   File: BuiltinHelperUnitTest.java    License: MIT License 5 votes vote down vote up
@Test
public void whenUsedIf_ThenPutsCondition() throws IOException {
    Handlebars handlebars = new Handlebars(templateLoader);
    Template template = handlebars.compile("if");
    Person person = getPerson("Baeldung");
    person.setBusy(true);

    String templateString = template.apply(person);

    assertThat(templateString).contains("<h4>Baeldung is busy.</h4>");
}
 
Example #23
Source Project: bonita-ui-designer   Author: bonitasoft   File: TemplateEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TemplateEngine(String template) {
    SimpleFilterProvider simpleFilterProvider = new SimpleFilterProvider();
    simpleFilterProvider.setFailOnUnknownId(false);
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setFilters(simpleFilterProvider);

    handlebars = new Handlebars(new ClassPathTemplateLoader("/", ""));
    handlebars.registerHelper("json", new Jackson2Helper(objectMapper));
    handlebars.registerHelper("join", StringHelpers.join);
    handlebars.registerHelper("ifequal", IfEqualHelper.INSTANCE);
    handlebars.prettyPrint(true);

    location = "templates/" + template;
}
 
Example #24
Source Project: flow   Author: vaadin   File: VaadinConnectTsGenerator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void addHandlebarHelpers(Handlebars handlebars) {
    super.addHandlebarHelpers(handlebars);
    handlebars.registerHelper("multiplelines", getMultipleLinesHelper());
    handlebars.registerHelper("getClassNameFromImports",
            getClassNameFromImportsHelper());
    handlebars.registerHelper("getModelType", getModelTypeHelper());
    handlebars.registerHelper("getModelConstructor",
            getModelConstructorHelper());
}
 
Example #25
Source Project: sakai   Author: sakaiproject   File: PASystemImpl.java    License: Educational Community License v2.0 5 votes vote down vote up
@Override
public String getFooter() {
    StringBuilder result = new StringBuilder();

    I18n i18n = getI18n(this.getClass().getClassLoader(), "org.sakaiproject.pasystem.impl.i18n.pasystem");
    Handlebars handlebars = loadHandleBars(i18n);

    Session session = SessionManager.getCurrentSession();

    Map<String, Object> context = new HashMap<String, Object>();

    try {
        Template template = handlebars.compile("templates/shared_footer");

        context.put("portalCDNQuery", PortalUtils.getCDNQuery());
        context.put("sakai_csrf_token", session.getAttribute("sakai.csrf.token"));

        result.append(template.apply(context));
    } catch (IOException e) {
        log.warn("IOException while getting footer", e);
        return "";
    }

    result.append(getBannersFooter(handlebars, context));
    result.append(getPopupsFooter(handlebars, context));
    result.append(getTimezoneCheckFooter(handlebars, context));

    return result.toString();
}
 
Example #26
Source Project: sakai   Author: sakaiproject   File: PASystemImpl.java    License: Educational Community License v2.0 5 votes vote down vote up
private Handlebars loadHandleBars(final I18n i18n) {
    Handlebars handlebars = new Handlebars()
            .with(cache);

    handlebars.registerHelper("t", new Helper<Object>() {
        @Override
        public CharSequence apply(final Object context, final Options options) {
            String key = options.param(0);
            return i18n.t(key);
        }
    });

    return handlebars;
}
 
Example #27
Source Project: sakai   Author: sakaiproject   File: PASystemImpl.java    License: Educational Community License v2.0 5 votes vote down vote up
private String getBannersFooter(Handlebars handlebars, Map<String, Object> context) {
    try {
        Template template = handlebars.compile("templates/banner_footer");

        context.put("bannerJSON", getActiveBannersJSON());

        return template.apply(context);
    } catch (IOException e) {
        log.warn("IOException while getting banners footer", e);
        return "";
    }
}
 
Example #28
Source Project: sakai   Author: sakaiproject   File: PASystemImpl.java    License: Educational Community License v2.0 5 votes vote down vote up
private String getPopupsFooter(Handlebars handlebars, Map<String, Object> context) {
    Session session = SessionManager.getCurrentSession();
    User currentUser = UserDirectoryService.getCurrentUser();

    if (currentUser == null || currentUser.getId() == null || "".equals(currentUser.getId())) {
        return "";
    }

    try {
        if (session.getAttribute(POPUP_SCREEN_SHOWN) == null) {
            Popup popup = new PopupForUser(currentUser).getPopup();
            if (popup.isActiveNow()) {
                context.put("popupTemplate", popup.getTemplate());
                context.put("popupUuid", popup.getUuid());
                context.put("popup", true);

                if (currentUser.getId() != null) {
                    // Delivered!
                    session.setAttribute(POPUP_SCREEN_SHOWN, "true");
                }
            }
        }


        Template template = handlebars.compile("templates/popup_footer");
        return template.apply(context);
    } catch (IOException | MissingUuidException e) {
        log.warn("IOException while getting popups footer", e);
        return "";
    }
}
 
Example #29
Source Project: tutorials   Author: eugenp   File: BuiltinHelperUnitTest.java    License: MIT License 5 votes vote down vote up
@Test
public void whenUsedWith_ThenContextChanges() throws IOException {
    Handlebars handlebars = new Handlebars(templateLoader);
    Template template = handlebars.compile("with");
    Person person = getPerson("Baeldung");
    person.getAddress().setStreet("World");

    String templateString = template.apply(person);

    assertThat(templateString).contains("<h4>I live in World</h4>");
}
 
Example #30
Source Project: spark-template-engines   Author: perwendel   File: HandlebarsTemplateEngine.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a handlebars template engine
 *
 * @param resourceRoot the resource root
 */
public HandlebarsTemplateEngine(String resourceRoot) {
    TemplateLoader templateLoader = new ClassPathTemplateLoader();
    templateLoader.setPrefix(resourceRoot);
    templateLoader.setSuffix(null);

    handlebars = new Handlebars(templateLoader);

    // Set Guava cache.
    Cache<TemplateSource, Template> cache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES)
            .maximumSize(1000).build();

    handlebars = handlebars.with(new GuavaTemplateCache(cache));
}