@Test public void shouldMergeTemplateIntoStringWhenNoDotsIsAvailable() throws Exception { final String expectedBody = TemplatingTestUtils.getExpectedBody(); final String templateWithNoExtension = TemplatingTestUtils.TEMPLATE.replace(".html", ""); assertions.assertThat(templateWithNoExtension).doesNotEndWith(".html"); final String body = templateService.mergeTemplateIntoString(templateWithNoExtension, TemplatingTestUtils.MODEL_OBJECT); assertions.assertThat(body).isEqualTo(expectedBody); }
@Override public @NonNull String mergeTemplateIntoString(final @NonNull String templateReference, final @NonNull Map<String, Object> model) throws IOException, TemplateException { final String trimmedTemplateReference = templateReference.trim(); checkArgument(!isNullOrEmpty(trimmedTemplateReference), "The given templateName is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Mustache template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.mustache.suffix' in your application.properties file", expectedTemplateExtension(), getFileExtension(trimmedTemplateReference)); try { final Reader template = mustacheAutoConfiguration.mustacheTemplateLoader() .getTemplate(normalizeTemplateReference(trimmedTemplateReference)); return mustacheAutoConfiguration.mustacheCompiler(mustacheAutoConfiguration.mustacheTemplateLoader()) .compile(template) .execute(model); } catch (Exception e) { throw new TemplateException(e); } }
MustacheTemplateService implements TemplateService { @Override public @NonNull String mergeTemplateIntoString(final @NonNull String templateReference, final @NonNull Map<String, Object> model) throws IOException, TemplateException { final String trimmedTemplateReference = templateReference.trim(); checkArgument(!isNullOrEmpty(trimmedTemplateReference), "The given templateName is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Mustache template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.mustache.suffix' in your application.properties file", expectedTemplateExtension(), getFileExtension(trimmedTemplateReference)); try { final Reader template = mustacheAutoConfiguration.mustacheTemplateLoader() .getTemplate(normalizeTemplateReference(trimmedTemplateReference)); return mustacheAutoConfiguration.mustacheCompiler(mustacheAutoConfiguration.mustacheTemplateLoader()) .compile(template) .execute(model); } catch (Exception e) { throw new TemplateException(e); } } }
MustacheTemplateService implements TemplateService { @Override public @NonNull String mergeTemplateIntoString(final @NonNull String templateReference, final @NonNull Map<String, Object> model) throws IOException, TemplateException { final String trimmedTemplateReference = templateReference.trim(); checkArgument(!isNullOrEmpty(trimmedTemplateReference), "The given templateName is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Mustache template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.mustache.suffix' in your application.properties file", expectedTemplateExtension(), getFileExtension(trimmedTemplateReference)); try { final Reader template = mustacheAutoConfiguration.mustacheTemplateLoader() .getTemplate(normalizeTemplateReference(trimmedTemplateReference)); return mustacheAutoConfiguration.mustacheCompiler(mustacheAutoConfiguration.mustacheTemplateLoader()) .compile(template) .execute(model); } catch (Exception e) { throw new TemplateException(e); } }  }
MustacheTemplateService implements TemplateService { @Override public @NonNull String mergeTemplateIntoString(final @NonNull String templateReference, final @NonNull Map<String, Object> model) throws IOException, TemplateException { final String trimmedTemplateReference = templateReference.trim(); checkArgument(!isNullOrEmpty(trimmedTemplateReference), "The given templateName is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Mustache template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.mustache.suffix' in your application.properties file", expectedTemplateExtension(), getFileExtension(trimmedTemplateReference)); try { final Reader template = mustacheAutoConfiguration.mustacheTemplateLoader() .getTemplate(normalizeTemplateReference(trimmedTemplateReference)); return mustacheAutoConfiguration.mustacheCompiler(mustacheAutoConfiguration.mustacheTemplateLoader()) .compile(template) .execute(model); } catch (Exception e) { throw new TemplateException(e); } }  @Override @NonNull String mergeTemplateIntoString(final @NonNull String templateReference,
                                   final @NonNull Map<String, Object> model); @Override String expectedTemplateExtension(); }
MustacheTemplateService implements TemplateService { @Override public @NonNull String mergeTemplateIntoString(final @NonNull String templateReference, final @NonNull Map<String, Object> model) throws IOException, TemplateException { final String trimmedTemplateReference = templateReference.trim(); checkArgument(!isNullOrEmpty(trimmedTemplateReference), "The given templateName is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Mustache template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.mustache.suffix' in your application.properties file", expectedTemplateExtension(), getFileExtension(trimmedTemplateReference)); try { final Reader template = mustacheAutoConfiguration.mustacheTemplateLoader() .getTemplate(normalizeTemplateReference(trimmedTemplateReference)); return mustacheAutoConfiguration.mustacheCompiler(mustacheAutoConfiguration.mustacheTemplateLoader()) .compile(template) .execute(model); } catch (Exception e) { throw new TemplateException(e); } }  @Override @NonNull String mergeTemplateIntoString(final @NonNull String templateReference,
                                   final @NonNull Map<String, Object> model); @Override String expectedTemplateExtension();  }