Thymeleaf With Dialect

A dialect for Thymeleaf that allows you to use attributes with a "with:" prefix to avoid having long "th:with"-expressions. Working with Thymeleaf 3.0.0+ (3.0.0.RELEASE and its dependencies included)

License

License

Categories

Categories

Leaf Data Databases
GroupId

GroupId

ch.mfrey.thymeleaf.extras.with
ArtifactId

ArtifactId

thymeleaf-with-dialect
Last Version

Last Version

3.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Thymeleaf With Dialect
A dialect for Thymeleaf that allows you to use attributes with a "with:" prefix to avoid having long "th:with"-expressions. Working with Thymeleaf 3.0.0+ (3.0.0.RELEASE and its dependencies included)
Project URL

Project URL

https://github.com/Antibrumm/thymeleaf-extras-with-dialect
Source Code Management

Source Code Management

https://github.com/Antibrumm/thymeleaf-extras-with-dialect.git

Download thymeleaf-with-dialect

How to add to project

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

Dependencies

provided (1)

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

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
ch.qos.logback : logback-classic jar 1.1.7

Project Modules

There are no modules declared in this project.

Thymeleaf With Dialect

A dialect for Thymeleaf that allows you to use attributes with a "with" prefix to avoid having long "th:with"-expressions.

Build Status

Requirements

  • Java 5
  • Thymeleaf 3.0.0+ (3.0.0.RELEASE and its dependencies included)

Installation

For Maven and Maven-compatible dependency managers

Add a dependency to your project with the following co-ordinates:

  • GroupId: ch.mfrey.thymeleaf.extras.with
  • ArtifactId: thymeleaf-with-dialect
  • Version: ${thymeleaf-with-dialect.version}

Usage

Add the With dialect to your existing Thymeleaf template engine, eg:

ServletContextTemplateResolver templateresolver = new ServletContextTemplateResolver();
templateresolver.setTemplateMode(TemplateMode.HTML);

templateengine = new TemplateEngine();
templateengine.setTemplateResolver(templateresolver);
templateengine.addDialect(new WithDialect());		// This line adds the dialect to Thymeleaf

Or, for those using Spring configuration files:

<bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
  <property name="templateMode" value="HTML5"/>
</bean>

<bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
  <property name="templateResolver" ref="templateResolver"/>

  <!-- These lines add the dialect to Thymeleaf -->
  <property name="additionalDialects">
    <set>
      <bean class="ch.mfrey.thymeleaf.extras.with.WithDialect" />
    </set>
  </property>

</bean>

Use it

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	xmlns:with="http://www.thymeleaf.org/extras/with">
<head></head>
<body>
	<div with:isActive="${true}"
	 	 with:hello="'Hello'"
	 	 with:helloWorld="${hello} + ' World'"
	 	 with:helloUnderWorld="${hello + ' Under World'}"
	 	 with:someCalc="${2 + 4}"
	 	 with:moreCalc="${someCalc + 10}">
		<div th:text="${isActive}">true</div>
		<div th:text="${hello}">Hello</div>
		<div th:text="${helloWorld}">Hello World</div>
		<div th:text="${helloUnderWorld}">Hello Under World</div>
		<div th:text="${someCalc}">6</div>
		<div th:text="${moreCalc}">16</div>
		<div with:evenMoreCalc="${moreCalc + 5}" th:text="${evenMoreCalc}">21</div>
	</div>
</body>
</html>

Changelog

0.0.1-SNAPSHOT

  • Initial commit.

1.0.0

  • Considered stable
  • Changed groupid

2.0.0

  • Working against Thymeleaf 2.1.0+

3.0.0-SNAPSHOT

  • Working against Thymeleaf 3.0.0.RELEASE

Versions

Version
3.0.1
3.0.0
2.0.0