com.github.spt-oss:thymeleaf-extras

Thymeleaf extra modules for customizing templates

Лицензия

Лицензия

Категории

Категории

Leaf Данные Базы данных
Группа

Группа

com.github.spt-oss
Идентификатор

Идентификатор

thymeleaf-extras
Последняя версия

Последняя версия

0.1.0
Дата

Дата

Тип

Тип

pom
Описание

Описание

Thymeleaf extra modules for customizing templates
Ссылка на сайт

Ссылка на сайт

https://github.com/spt-oss/thymeleaf-extras
Организация-разработчик

Организация-разработчик

SPT
Система контроля версий

Система контроля версий

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

Скачать thymeleaf-extras

Имя Файла Размер
thymeleaf-extras-0.1.0.pom 1 KB
Обзор

Как подключить последнюю версию

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

Зависимости

provided (1)

Идентификатор библиотеки Тип Версия
org.projectlombok : lombok jar 1.16.18

Модули Проекта

  • thymeleaf-extras-minify

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

Версии библиотеки

Версия
0.1.0