Class StandardTemplateResourceResolver

java.lang.Object
org.springframework.restdocs.templates.StandardTemplateResourceResolver
All Implemented Interfaces:
TemplateResourceResolver

public class StandardTemplateResourceResolver extends Object implements TemplateResourceResolver
Standard implementation of TemplateResourceResolver.

Templates are resolved by looking for resources on the classpath. The following locations are checked in order:

  1. org/springframework/restdocs/templates/${templateFormatId}/${name}.snippet
  2. org/springframework/restdocs/templates/${name}.snippet
  3. org/springframework/restdocs/templates/${templateFormatId}/default-${name}.snippet
Author:
Andy Wilkinson
See Also:
  • Constructor Details

    • StandardTemplateResourceResolver

      public StandardTemplateResourceResolver(TemplateFormat templateFormat)
      Creates a new StandardTemplateResourceResolver that will produce default template resources formatted with the given templateFormat.
      Parameters:
      templateFormat - the format for the default snippet templates
  • Method Details

    • resolveTemplateResource

      public org.springframework.core.io.Resource resolveTemplateResource(String name)
      Description copied from interface: TemplateResourceResolver
      Resolves a Resource for the template with the given name.
      Specified by:
      resolveTemplateResource in interface TemplateResourceResolver
      Parameters:
      name - the name of the template
      Returns:
      the Resource from which the template can be read