@Test public void shouldNotAcceptEmptyTemplateName() throws Exception { final Map<String, Object> modelObject = new ImmutableMap.Builder<String, Object>() .build(); expectedException.expect(IllegalArgumentException.class); templateService.mergeTemplateIntoString(" ", modelObject); fail("IllegalArgumentException expected"); }
@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();  }