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

    Constructors
    Constructor
    Description
    MustacheViewDriver(com.github.mustachejava.MustacheFactory mustacheFactory)
    Creates a Mustache View Driver using the provided MustacheFactory.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract boolean
    Checks if this handler should process a view by its view name.
    static com.github.mustachejava.DefaultMustacheFactory
    Creates a new DefaultMustacheFactory using a class path root.
    static com.github.mustachejava.DefaultMustacheFactory
    Creates a new DefaultMustacheFactory 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static com.github.mustachejava.DefaultMustacheFactory createFileMustacheFactory(File root)
      Creates a new DefaultMustacheFactory 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 new DefaultMustacheFactory 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

      public void setMimeType(String mimeType)
      Sets the forced MIME-Type.
      Parameters:
      mimeType - the forced MIME-type for the output.
    • acceptViewName

      protected abstract boolean acceptViewName(String viewName)
      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 interface com.blackrook.small.roles.ViewDriver
      Throws:
      com.blackrook.small.exception.views.ViewProcessingException