This Starter provides you the minimal and required configuration to use jade templates as views in your Spring Boot application.
Behind the scenes, this starter uses the jade4j and spring-jade4j libraries.
The usage is pretty straightforward as you can expect for any Starter.
build.gradle
...
dependencies {
compile "com.domingosuarez.boot:spring-boot-starter-jade4j:0.3.1"
}
...
pom.xml
<project>
...
<dependencies>
<dependency>
<groupId>com.domingosuarez.boot</groupId>
<artifactId>spring-boot-starter-jade4j</artifactId>
<version>0.3.1</version>
</dependency>
</dependencies>
</project>
You can add helpers automatically using the annotation @JadeHelper
package demo;
import com.domingosuarez.boot.autoconfigure.jade4j.JadeHelper;
@JadeHelper
public class Util {
public String format(double number) {
return "some formating";
}
}
template.jade
html head title Hello body h h1 #{util.format(4)} # (1)
-
The helper name’s is the Spring Bean id
You can customize the helper’s name using the JadeHelper annotation
package demo;
import com.domingosuarez.boot.autoconfigure.jade4j.JadeHelper;
@JadeHelper("myId") // (1)
public class Util {
public String format(double number) {
return "some formating";
}
}
-
The new id
template.jade
html head title Hello body h h1 #{myId.format(4)}
The following settings are available:
Setting key | Type | Default value |
---|---|---|
spring.jade4j.checkTemplateLocation |
Boolean |
true |
spring.jade4j.prefix |
String |
'classpath:/templates/' |
spring.jade4j.suffix |
String |
'.jade' |
spring.jade4j.encoding |
String |
'UTF-8' |
spring.jade4j.caching |
Boolean |
true |
spring.jade4j.prettyPrint |
Boolean |
false |
spring.jade4j.mode |
String |
'HTML' |
spring.jade4j.contentType |
String |
'text/html' |
spring.jade4j.resolver.order |
Integer |
Ordered.LOWEST_PRECEDENCE - 50 |
Please take a look into this application if you want to checkout a fully application.