public class MustacheTemplateEngine extends Object implements TemplateEngine
TemplateEngine
implemented using JMustache.
Note that JMustache has been repackaged and embedded to prevent classpath conflicts.
Constructor and Description |
---|
MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver)
Creates a new
MustacheTemplateEngine that will use the given
templateResourceResolver to resolve template paths. |
MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver,
org.springframework.restdocs.mustache.Mustache.Compiler compiler)
Creates a new
MustacheTemplateEngine that will use the given
templateResourceResolver to resolve templates and the given
compiler to compile them. |
MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver,
org.springframework.restdocs.mustache.Mustache.Compiler compiler,
Map<String,Object> context)
Creates a new
MustacheTemplateEngine that will use the given
templateResourceResolver to resolve templates and the given
compiler to compile them. |
Modifier and Type | Method and Description |
---|---|
Template |
compileTemplate(String name)
Compiles the template at the given
path . |
protected org.springframework.restdocs.mustache.Mustache.Compiler |
getCompiler()
Returns the
Mustache.Compiler used to compile Mustache templates. |
protected TemplateResourceResolver |
getTemplateResourceResolver()
Returns the
TemplateResourceResolver used to resolve the template resources
prior to compilation. |
public MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver)
MustacheTemplateEngine
that will use the given
templateResourceResolver
to resolve template paths.templateResourceResolver
- the resolver to usepublic MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver, org.springframework.restdocs.mustache.Mustache.Compiler compiler)
MustacheTemplateEngine
that will use the given
templateResourceResolver
to resolve templates and the given
compiler
to compile them.templateResourceResolver
- the resolver to usecompiler
- the compiler to usepublic MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver, org.springframework.restdocs.mustache.Mustache.Compiler compiler, Map<String,Object> context)
MustacheTemplateEngine
that will use the given
templateResourceResolver
to resolve templates and the given
compiler
to compile them. Compiled templates will be created with the given
context
.templateResourceResolver
- the resolver to usecompiler
- the compiler to usecontext
- the context to pass to compiled templatesMustacheTemplate.MustacheTemplate(org.springframework.restdocs.mustache.Template,
Map)
public Template compileTemplate(String name) throws IOException
TemplateEngine
path
. Typically, a
TemplateResourceResolver
will be used to resolve the path into a resource
that can be read and compiled.compileTemplate
in interface TemplateEngine
name
- the path of the templateTemplate
IOException
- if compilation failsprotected final org.springframework.restdocs.mustache.Mustache.Compiler getCompiler()
Mustache.Compiler
used to compile Mustache templates.protected final TemplateResourceResolver getTemplateResourceResolver()
TemplateResourceResolver
used to resolve the template resources
prior to compilation.