Package com.github.jknack.handlebars.io
Interface TemplateLoader
-
- All Known Implementing Classes:
AbstractTemplateLoader,ClassPathTemplateLoader,CompositeTemplateLoader,FileTemplateLoader,ServletContextTemplateLoader,URLTemplateLoader
public interface TemplateLoaderStrategy interface for loading resources from class path, file system, etc.
Templates prefix and suffix
A
TemplateLoaderprovides 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:
- 0.1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_PREFIXThe default view prefix.static java.lang.StringDEFAULT_SUFFIXThe default view suffix.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.nio.charset.CharsetgetCharset()java.lang.StringgetPrefix()java.lang.StringgetSuffix()java.lang.Stringresolve(java.lang.String location)Resolve a relative location to an absolute location.voidsetCharset(java.nio.charset.Charset charset)Set the default charset.voidsetPrefix(java.lang.String prefix)Set the prefix that gets prepended to view names when building a URI.voidsetSuffix(java.lang.String suffix)Set the suffix that gets appended to view names when building a URI.TemplateSourcesourceAt(java.lang.String location)Get a template source from location.
-
-
-
Field Detail
-
DEFAULT_PREFIX
static final java.lang.String DEFAULT_PREFIX
The default view prefix.- See Also:
- Constant Field Values
-
DEFAULT_SUFFIX
static final java.lang.String DEFAULT_SUFFIX
The default view suffix.- See Also:
- Constant Field Values
-
-
Method Detail
-
sourceAt
TemplateSource sourceAt(java.lang.String location) throws java.io.IOException
Get a template source from location.- Parameters:
location- The location of the template source. Required.- Returns:
- A new template source.
- Throws:
java.io.IOException- If the template's source can't be resolved.
-
resolve
java.lang.String resolve(java.lang.String location)
Resolve a relative location to an absolute location.- Parameters:
location- The candidate location.- Returns:
- Resolve the uri to an absolute location.
-
getPrefix
java.lang.String getPrefix()
- Returns:
- The prefix that gets prepended to view names when building a URI.
-
getSuffix
java.lang.String getSuffix()
- Returns:
- The suffix that gets appended to view names when building a URI.
-
setPrefix
void setPrefix(java.lang.String prefix)
Set the prefix that gets prepended to view names when building a URI.- Parameters:
prefix- The prefix that gets prepended to view names when building a URI.
-
setSuffix
void setSuffix(java.lang.String suffix)
Set the suffix that gets appended to view names when building a URI.- Parameters:
suffix- The suffix that gets appended to view names when building a URI.
-
setCharset
void setCharset(java.nio.charset.Charset charset)
Set the default charset.- Parameters:
charset- Charset.
-
getCharset
java.nio.charset.Charset getCharset()
- Returns:
- Charset.
-
-