-
Notifications
You must be signed in to change notification settings - Fork 4
08. Advanced Features
In this option we describe the advanced features and configurations
There are some options for templating:
- Groovy Templates (default)
- It is a very powerful JSP like template engine where in EL expressions you can use groovy code
- See documentation at http://groovy.codehaus.org/Groovy+Templates
- Using Groovy Template, we need to encode some chars in .tmpl files:
- all '' as '\\' (known Issue: https://jira.codehaus.org/browse/GROOVY-2939)
- all '$' as '$' (because it is a char to execute EL expressions)
- Apache Velocity
- It is a very well known (for Java developers) template engine which, unfortunately, is not being updated lately
- See documentation at https://velocity.apache.org/engine/releases/velocity-1.7/user-guide.html
- Mustache
- It is a very well known (for JavaScript developers) and powerful template engine
- See documentation at http://mustache.github.io/mustache.5.html OR https://github.com/spullara/mustache.java
- Handlebars
- It is a super set of Mustache template engine
- See documentation at https://github.com/jknack/handlebars.java
The default template engine is Groovy Templates. However, you change this on settings in build.gradle file. For example:
scd4j {
install {
modules ..
config ..
}
settings {
template {
engine "mustache"
}
}
}The options you can provide in 'settings - template - engine' are:
- groovy for Groovy Templates (default)
- velocity for Apache Velocity
- mustache for Mustache
- handlebars for Handlebars
SCD4J also allows you to use variables to define the directory and/or file names. The syntax to use this feature requires that you define the name of the variable between @. For example:
modules/
my_module/
Module.hook
my_dir_@varName@/
file_@anotherVarName@.txt
In the above example, you can see two variables being used: (1) varName to define the name of the directory and (2) anotherVarName to define the name of the file.
Those variables may be set in the scd4j config file or programatically using methods defined in ModuleHook.java or FileHook.java, depending the objective.