public abstract class URLTemplateLoader extends AbstractTemplateLoader
Strategy interface for loading resources (i.e class path or file system resources)
A TemplateLoader
provides two important properties:
'.hbs'
Usage:
TemplateLoader loader = new ClassPathTemplateLoader(); loader.setPrefix("/templates"); loader.setSuffix(".html"); Handlebars handlebars = new Handlebars(loader); Template template = handlebars.compile("mytemplate"); System.out.println(template.apply("Handlebars.java"));
The template loader resolve mytemplate
to /templates/mytemplate.html
and load it.
DEFAULT_PREFIX, DEFAULT_SUFFIX
Constructor and Description |
---|
URLTemplateLoader() |
Modifier and Type | Method and Description |
---|---|
TemplateSource |
sourceAt(java.lang.String uri)
Get a template source from location.
|
public TemplateSource sourceAt(java.lang.String uri) throws java.io.IOException
TemplateLoader
uri
- The location of the template source. Required.java.io.IOException
- If the template's source can't be resolved.Copyright © 2010 - 2020 Adobe. All Rights Reserved