Class HandlebarsTemplateCompilerTask
- All Implemented Interfaces:
BuildTask
HandlebarsTemplateCompilerConfig.getTargetDataField()
data field.
Template name is looked up from data field named HandlebarsTemplateCompilerConfig.getTemplateDataField()
()}
either on page's data or from its parent nodes all the way up using first value found. If no value is found, will
use default template defined in HandlebarsTemplateCompilerConfig.getDefaultTemplate()
.
Templates' context has the following variables available:
- page: which is of type
DataPage
and is the current page being compiled - node: which is of type
DataNode
and is the parent of current page being compiled - root: which is of type
DataNode
and refers to root node ofinvalid reference
BuildContext#getDataTree()
- buildContext: which is of type
BuildContext
and is the whole build context and data
Custom helpers might be added either as Java helpers or as JavaScript helpers.
As for Java helpers, the class name has to be passed on HandlebarsTemplateCompilerConfig.getHelpers()
list.
For each class, all the public instance methods are registered as helpers with same name.
Those classes are expected to have zero arg constructor.
Java helpers can use SLF4J for logging. This will be then appended to default application's logs and will
be visible for users.
More information can be found under "Helper Source" part of external documentation.
There is also a possibility of writing helpers in JavaScript, which is mostly suitable for cases when a helper is
very specific or does not make sense to be reused. JavaScript helpers can be registered by passing their file name
in HandlebarsTemplateCompilerConfig.getHelpers()
list. Inside the JavaScript file multiple helpers can be
registered using following syntax:
Handlebars.registerHelper('hey', function (context) {
return 'Hi ' + context.name;
});
For more info about helpers refer to external documentation
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
run
(BuildContext buildContext) If a plugin depends on config files in addition to the general config file of the application, like functionality extensions stored in files, it shall return these paths here.If a plugin depends on file input, it shall return list of its input paths to be watched for changes.
-
Constructor Details
-
HandlebarsTemplateCompilerTask
-
-
Method Details
-
run
-
underWatchInputPaths
Description copied from interface:BuildTask
If a plugin depends on file input, it shall return list of its input paths to be watched for changes. Paths can be either files or directories. In case of directories, only root path are necessary to be listed and if input path has subdirectories, they will be automatically watched.- Specified by:
underWatchInputPaths
in interfaceBuildTask
-
underWatchConfigPaths
Description copied from interface:BuildTask
If a plugin depends on config files in addition to the general config file of the application, like functionality extensions stored in files, it shall return these paths here. A change detected in these paths will result in recreation of the plugin.- Specified by:
underWatchConfigPaths
in interfaceBuildTask
-