Static Site Builder Util (SBU) 1.0 Documentation
A file handler is resonsible for the building of result files (target files) from source files. SBU comes with two build-in file handlers.
The binary file filter copies files without transforming the content. This is useful for output resources like CSS or image files. It provides an optional 'buffer-size' attribute where the user may set a custom buffer size in bytes.
The FTL file handler is the "heart" of the build-in implementation of SBU. It uses FREEMARKER for transforming a source text file into a corresponding target file by using a layout FTL template. The related JAVA class is de.dv.sbu.filehandler.ftl.FtlFileHandler. Read the FREEMARKER documentation for knowledge about using the templating functionality.
The transformation consists of the following step:
The configuration includes the following properties (attributes and child elements):
name | description | XML respresentation | required | default |
---|---|---|---|---|
layout-template | Path to the FTL template file (relative to the resources root). | element | required | |
encoding | The charset to be used during proceedin. | element | false | UTF-8 |
locale | The current source file information. Two attributes: language and country. The first should be set. | element | false | system |
data-providers | Defined data providers. Accessable by the defined name. | map of elements | false | |
forced-suffix | The charset to be used during proceedin. | element | false | |
source parser | The source parser to use. | element | false | default source parser |
overlay | As many overlay definitions as you want (see below). | list of elements | false |
Data providers are of type de.dv.sbu.filehandler.ftl.dataprovider.IDataProvider. An identifying name has to be specified for each used data provider. The source file will be parsed by a Source File Parser. This is an optional property of type de.dv.sbu.filehandler.ftl.ISourceParser.
Overlays allow to redefine certain properties depending on a file filter. If the filter matches (the first hit wins), all defined propeties will override the original ones. The following properties can be redefined:
name | description | XML respresentation | required |
---|---|---|---|
layout-template | Path to the FTL template file (relative to the resources root). | element | false |
encoding | The charset to be used during proceedin. | element | false |
locale | The current source file information. Two attributes: language and country. The first should be set. | element | false |
forced-suffix | The charset to be used during proceedin. | element | false |
source parser | The source parser to use. | element | false |
An example:
<ftl-file-handler> <layout-template>/layout.ftl</layout-template> <encoding>UTF8</encoding> <locale country="GB" language="en"/> <overlay> <suffix-filter suffix="xde"/> <locale country="" language="de"/> <forced-suffix>htm</forced-suffix> </overlay> </ftl-file-handler>
Before proceeding the source file parsing, a set of objects will be registered in the root map that will be passed to the FREEMARKER engine proceeding the layout template file and can be used there.
Name | Description | Java Class |
---|---|---|
configuration | The used builder configuration instance. | de.dv.sbu.builder.BuilderConfiguration |
file | The current source file information. | de.dv.sbu.SourceFileInformation |
dataprovider | Defined data providers. Accessable by name. | java.util.List <de.dv.sbu.filehandler.ftl.dataprovider.IDataProvider> |
content | The text resulting from the current source file after proceeding the source parser. | java.lang.String |
The used source parser may add additional obects.
previous page next page