com.github.spt-oss:thymeleaf-extras-minify

Thymeleaf extra modules for customizing templates

License

License

Categories

Categories

Leaf Data Databases
GroupId

GroupId

com.github.spt-oss
ArtifactId

ArtifactId

thymeleaf-extras-minify
Last Version

Last Version

3.0.11.0
Release Date

Release Date

Type

Type

jar
Description

Description

Thymeleaf extra modules for customizing templates
Project Organization

Project Organization

SPT
Source Code Management

Source Code Management

https://github.com/spt-oss/thymeleaf-extras/tree/master/thymeleaf-extras-minify

Download thymeleaf-extras-minify

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.spt-oss/thymeleaf-extras-minify/ -->
<dependency>
    <groupId>com.github.spt-oss</groupId>
    <artifactId>thymeleaf-extras-minify</artifactId>
    <version>3.0.11.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.spt-oss/thymeleaf-extras-minify/
implementation 'com.github.spt-oss:thymeleaf-extras-minify:3.0.11.0'
// https://jarcasting.com/artifacts/com.github.spt-oss/thymeleaf-extras-minify/
implementation ("com.github.spt-oss:thymeleaf-extras-minify:3.0.11.0")
'com.github.spt-oss:thymeleaf-extras-minify:jar:3.0.11.0'
<dependency org="com.github.spt-oss" name="thymeleaf-extras-minify" rev="3.0.11.0">
  <artifact name="thymeleaf-extras-minify" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.spt-oss', module='thymeleaf-extras-minify', version='3.0.11.0')
)
libraryDependencies += "com.github.spt-oss" % "thymeleaf-extras-minify" % "3.0.11.0"
[com.github.spt-oss/thymeleaf-extras-minify "3.0.11.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.thymeleaf : thymeleaf jar 3.0.11.RELEASE

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.4

test (1)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 2.0.6.RELEASE

Project Modules

There are no modules declared in this project.

Thymeleaf Extras

circleci maven central javadoc

  • Thymeleaf extra modules for customizing templates
  • Note: This project is unofficial and experimental.

TOC

thymeleaf-extras-minify

Example

  • Thymeleaf template
     <!DOCTYPE html>
     <html xmlns:th="http://www.thymeleaf.org">
     
     <!-- head -->
     <head>
         <meta charset="utf-8" />
         <title th:text="bar">foo</title>
         <style>
         body {
           font-size: 1rem;
         }
         </style>
     ......
  • Processed HTML
     <!DOCTYPE html><html><head><meta charset="utf-8" /><title>bar</title><style>body { font-size: 1rem; }</style>......

Usage

  1. Add a dependency in your project.

    <dependency>
        <groupId>com.github.spt-oss</groupId>
        <artifactId>thymeleaf-extras-minify</artifactId>
        <version>3.0.11.0</version>
    </dependency>
  2. Add the MinifierDialect to the TemplateEngine instance.

    import org.thymeleaf.TemplateEngine;
    import org.thymeleaf.extras.minify.dialect.MinifierDialect;
    
    TemplateEngine engine = new TemplateEngine();
    engine.addDialect(new MinifierDialect());
  3. Or setup Spring configurations if your project is based on Spring Boot.

    spring.thymeleaf:
        prefix: classpath:/templates/
    import org.springframework.context.annotation.Bean;
    import org.thymeleaf.extras.minify.dialect.MinifierDialect;
    
    @Bean
    public MinifierDialect minifierDialect() {
        return new MinifierDialect();
    }

Customization

  1. Create a subclass of AbstractMinifierTemplateHandler or SimpleMinifierTemplateHandler.

    package my.project;
    
    import org.thymeleaf.extras.minify.engine.AbstractMinifierTemplateHandler;
    
    public class MyMinifierTemplateHandler extends AbstractMinifierTemplateHandler {
        ......
    }
  2. Set the class to the first argument of the MinifierDialect. Note that only class type is accepted because of Thymeleaf processor's restriction.

    import my.project.MyMinifierTemplateHandler;
    
    TemplateEngine engine = new TemplateEngine();
    engine.addDialect(new MinifierDialect(MyMinifierTemplateHandler.class));
    import my.project.MyMinifierTemplateHandler;
    
    @Bean
    public MinifierDialect minifierDialect() {
        return new MinifierDialect(MyMinifierTemplateHandler.class);
    }

References

License

  • This software is released under the Apache License 2.0.
com.github.spt-oss

SPT

Open Source Libraries for Java

Versions

Version
3.0.11.0
0.1.0