public class TemplateManager extends Object implements TemplatingExecutor, TemplateProcessor
| Constructor and Description |
|---|
TemplateManager(TemplateManagerOptions options,
TemplatingEngineAdapter engineAdapter,
TemplatePathLocator[] templateLoaders)
Constructs a new instance of a
TemplateManager |
| Modifier and Type | Method and Description |
|---|---|
static String |
getCPResourcePath(String name)
Gets a normalized classpath resource location according to OS-specific file separator
|
String |
getFullTemplateContents(String name)
returns the template content by name
|
Path |
getFullTemplatePath(String name)
Returns the path of a template, allowing access to the template where consuming literal contents aren't desirable or possible.
|
Reader |
getTemplateReader(String name) |
void |
ignore(Path path,
String context) |
String |
readTemplate(String name)
Reads a template's contents from the specified location
|
void |
skip(Path path,
String context) |
File |
write(Map<String,Object> data,
String template,
File target)
Writes data to a compiled template
|
File |
writeToFile(String filename,
byte[] contents)
Write bytes to a file
|
File |
writeToFile(String filename,
String contents)
Write String to a file, formatting as UTF-8
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waiterrorpublic TemplateManager(TemplateManagerOptions options, TemplatingEngineAdapter engineAdapter, TemplatePathLocator[] templateLoaders)
TemplateManageroptions - The TemplateManagerOptions for reading and writing templatesengineAdapter - The adaptor to underlying templating enginetemplateLoaders - Loaders which define where we look for templatespublic String getFullTemplateContents(String name)
getFullTemplateContents in interface TemplatingExecutorname - the template name (e.g. model.mustache)public Path getFullTemplatePath(String name)
getFullTemplatePath in interface TemplatingExecutorname - the template name (e.g. model.mustache)Path to the templatepublic static String getCPResourcePath(String name)
name - The name of the resource file/directory to findpublic String readTemplate(String name)
name - The location of the templatepublic File write(Map<String,Object> data, String template, File target) throws IOException
write in interface TemplateProcessordata - Input datatemplate - Input template locationtarget - The targeted file output locationIOExceptionpublic void ignore(Path path, String context)
ignore in interface TemplateProcessorpublic void skip(Path path, String context)
skip in interface TemplateProcessorpublic File writeToFile(String filename, String contents) throws IOException
filename - The name of file to writecontents - The contents string.IOException - If file cannot be written.public File writeToFile(String filename, byte[] contents) throws IOException
writeToFile in interface TemplateProcessorfilename - The name of file to writecontents - The contents bytes. Typically, this is a UTF-8 formatted string.IOException - If file cannot be written.Copyright © 2021. All rights reserved.