@Test public void shouldMergeTemplateIntoString() throws Exception { final String expectedBody = TemplatingTestUtils.getExpectedBody(); final String templateWithExtension = TemplatingTestUtils.TEMPLATE; assertions.assertThat(templateWithExtension).endsWith(".html"); final String body = templateService.mergeTemplateIntoString(templateWithExtension, 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 template is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getNormalizedFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Thymeleaf template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.thymeleaf.suffix' in your application.properties file", expectedTemplateExtension(), getNormalizedFileExtension(trimmedTemplateReference)); final Context context = new Context(); context.setVariables(model); return thymeleafEngine.process(FilenameUtils.removeExtension(trimmedTemplateReference), context); }
ThymeleafTemplateService 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 template is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getNormalizedFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Thymeleaf template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.thymeleaf.suffix' in your application.properties file", expectedTemplateExtension(), getNormalizedFileExtension(trimmedTemplateReference)); final Context context = new Context(); context.setVariables(model); return thymeleafEngine.process(FilenameUtils.removeExtension(trimmedTemplateReference), context); } }
ThymeleafTemplateService 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 template is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getNormalizedFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Thymeleaf template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.thymeleaf.suffix' in your application.properties file", expectedTemplateExtension(), getNormalizedFileExtension(trimmedTemplateReference)); final Context context = new Context(); context.setVariables(model); return thymeleafEngine.process(FilenameUtils.removeExtension(trimmedTemplateReference), context); }  }
ThymeleafTemplateService 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 template is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getNormalizedFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Thymeleaf template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.thymeleaf.suffix' in your application.properties file", expectedTemplateExtension(), getNormalizedFileExtension(trimmedTemplateReference)); final Context context = new Context(); context.setVariables(model); return thymeleafEngine.process(FilenameUtils.removeExtension(trimmedTemplateReference), context); }  @Override @NonNull String mergeTemplateIntoString(final @NonNull String templateReference,
                                   final @NonNull Map<String, Object> model); @Override String expectedTemplateExtension(); }
ThymeleafTemplateService 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 template is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getNormalizedFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Thymeleaf template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.thymeleaf.suffix' in your application.properties file", expectedTemplateExtension(), getNormalizedFileExtension(trimmedTemplateReference)); final Context context = new Context(); context.setVariables(model); return thymeleafEngine.process(FilenameUtils.removeExtension(trimmedTemplateReference), context); }  @Override @NonNull String mergeTemplateIntoString(final @NonNull String templateReference,
                                   final @NonNull Map<String, Object> model); @Override String expectedTemplateExtension();  }