Class MustacheViewDriver
java.lang.Object
com.blackrook.small.views.mustache.MustacheViewDriver
- All Implemented Interfaces:
com.blackrook.small.roles.ViewDriver
public abstract class MustacheViewDriver
extends Object
implements com.blackrook.small.roles.ViewDriver
The Mustache View Driver for Small.
- Author:
- Matthew Tropiano
-
Constructor Summary
ConstructorDescriptionMustacheViewDriver
(com.github.mustachejava.MustacheFactory mustacheFactory) Creates a Mustache View Driver using the provided MustacheFactory. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract boolean
acceptViewName
(String viewName) Checks if this handler should process a view by its view name.static com.github.mustachejava.DefaultMustacheFactory
createClasspathMustacheFactory
(String classPathRoot) Creates a newDefaultMustacheFactory
using a class path root.static com.github.mustachejava.DefaultMustacheFactory
Creates a newDefaultMustacheFactory
using a file root.boolean
handleView
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object model, String viewName) void
setMimeType
(String mimeType) Sets the forced MIME-Type.
-
Constructor Details
-
MustacheViewDriver
public MustacheViewDriver(com.github.mustachejava.MustacheFactory mustacheFactory) Creates a Mustache View Driver using the provided MustacheFactory.- Parameters:
mustacheFactory
- the factory to use for the Mustache driver.
-
-
Method Details
-
createFileMustacheFactory
Creates a newDefaultMustacheFactory
using a file root. The root file should be a directory containing your Mustache templates.- Parameters:
root
- the file root.- Returns:
- the created factory.
-
createClasspathMustacheFactory
public static com.github.mustachejava.DefaultMustacheFactory createClasspathMustacheFactory(String classPathRoot) Creates a newDefaultMustacheFactory
using a class path root. The root should be a directory containing your Mustache templates.- Parameters:
classPathRoot
- the class path root.- Returns:
- the created factory.
-
setMimeType
Sets the forced MIME-Type.- Parameters:
mimeType
- the forced MIME-type for the output.
-
acceptViewName
Checks if this handler should process a view by its view name. If false is returned, this view driver is skipped.- Parameters:
viewName
- the name of the view to process.- Returns:
- true if so, false if not.
-
handleView
public boolean handleView(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object model, String viewName) throws com.blackrook.small.exception.views.ViewProcessingException - Specified by:
handleView
in interfacecom.blackrook.small.roles.ViewDriver
- Throws:
com.blackrook.small.exception.views.ViewProcessingException
-