Class AbstractTemplateLoader

java.lang.Object
com.github.jknack.handlebars.io.AbstractTemplateLoader
All Implemented Interfaces:
TemplateLoader
Direct Known Subclasses:
URLTemplateLoader

public abstract class AbstractTemplateLoader extends Object implements TemplateLoader

Strategy interface for loading resources from class path, file system, etc.

Templates prefix and suffix

A TemplateLoader provides two important properties:

  • prefix: useful for setting a default prefix where templates are stored.
  • suffix: useful for setting a default suffix or file extension for your templates. Default is: '.hbs'
Since:
1.0.0
  • Constructor Details

    • AbstractTemplateLoader

      public AbstractTemplateLoader()
  • Method Details

    • resolve

      public String resolve(String uri)
      Resolve the uri to an absolute location.
      Specified by:
      resolve in interface TemplateLoader
      Parameters:
      uri - The candidate uri.
      Returns:
      Resolve the uri to an absolute location.
    • setPrefix

      public void setPrefix(String prefix)
      Set the prefix that gets prepended to view names when building a URI.
      Specified by:
      setPrefix in interface TemplateLoader
      Parameters:
      prefix - The prefix that gets prepended to view names when building a URI.
    • setSuffix

      public void setSuffix(String suffix)
      Set the suffix that gets appended to view names when building a URI.
      Specified by:
      setSuffix in interface TemplateLoader
      Parameters:
      suffix - The suffix that gets appended to view names when building a URI.
    • setCharset

      public void setCharset(Charset charset)
      Description copied from interface: TemplateLoader
      Set the default charset.
      Specified by:
      setCharset in interface TemplateLoader
      Parameters:
      charset - Charset.
    • getCharset

      public Charset getCharset()
      Specified by:
      getCharset in interface TemplateLoader
      Returns:
      Charset.
    • getPrefix

      public String getPrefix()
      Specified by:
      getPrefix in interface TemplateLoader
      Returns:
      The prefix that gets prepended to view names when building a URI.
    • getSuffix

      public String getSuffix()
      Specified by:
      getSuffix in interface TemplateLoader
      Returns:
      The suffix that gets appended to view names when building a URI.