• Stars
    star
    700
  • Rank 62,070 (Top 2 %)
  • Language
    Groovy
  • License
    Apache License 2.0
  • Created almost 12 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A dialect for Thymeleaf that lets you build layouts and reusable templates in order to improve code reuse

Thymeleaf Layout Dialect

Build Status codecov Maven Central

A dialect for Thymeleaf that lets you build layouts and reusable templates in order to improve code reuse.

Documentation

All of the latest documentation on the layout dialect can be found on the dedicated docs website at https://ultraq.github.io/thymeleaf-layout-dialect/

For version 1 docs which supported Thymeleaf 2, the classic readme still exists over on https://github.com/ultraq/thymeleaf-layout-dialect/tree/1.4.0

What does it do?

The Thymeleaf Layout Dialect adds the ability to decorate templates - automatically for the <head> section of an HTML template, and explicitly through extension points that developers can add to their templates. This all adds up to create layouts that can be extended in a manner similar to classical inheritence.

For example, given a common layout.html file, set some shared static assets in the <head> and define extension points in the body with the layout:fragment processor:

<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
  <title>Layout page</title>
  <script src="common-script.js"></script>
</head>
<body>
  <header>
    <h1>My website</h1>
  </header>
  <section layout:fragment="content">
    <p>Page content goes here</p>
  </section>
</body>
</html>

Create a content template that will define its own title, static resources, and replacements for those extension points. Link the page to the layout by using the layout:decorate processor at the root element of the page which will instruct Thymeleaf to decorate the layout with this template:

<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
  layout:decorate="~{layout.html}">
<head>
  <title>Content page</title>
  <script src="content-script.js"></script>
</head>
<body>
  <section layout:fragment="content">
    <p>This is a paragraph from the content page</p>
  </section>
</body>
</html>

When Thymeleaf processes your content template, the resulting HTML will be:

<!DOCTYPE html>
<html>
<head>
  <title>Content page</title>
  <script src="common-script.js"></script>
  <script src="content-script.js"></script>
</head>
<body>
  <header>
    <h1>My website</h1>
  </header>
  <section>
    <p>This is a paragraph from the content page</p>
  </section>
</body>
</html>

Learn more

Check out the getting started guide to learn how to add the layout dialect to your Thymeleaf project, or read up on the many processors for more ways of how the layout dialect can help you build your templates.

More Repositories

1

thymeleafjs

A basic implementation of the Thymeleaf templating engine in JavaScript
JavaScript
51
star
2

thymeleaf-layout-dialect-js

In-browser version of the Thymeleaf Layout Dialect, used for static prototyping
JavaScript
7
star
3

redhorizon

Recreating the original 2D Command & Conquer games
Groovy
6
star
4

icu-message-formatter

Format ICU message syntax strings from supplied parameters and your own configurable types
JavaScript
5
star
5

thymeleafjs-todo

Example project for showcasing ThymeleafJS
JavaScript
5
star
6

jaxb-utilities

An alternative API for working with XML files using JAXB
Groovy
5
star
7

preferences-xml

An implementation of the Java Preferences API (java.util.prefs) to store preferences in an XML file, in a subdirectory of a Java program's working directory.
Groovy
5
star
8

gradle-support

A bunch of Gradle scripts that help support my workflow
4
star
9

express-thymeleaf

Integrate ThymeleafJS with Express
JavaScript
4
star
10

react-icu-message-formatter

React wrapper for the lightweight ICU message formatter
JavaScript
3
star
11

preferences

A simplified and typesafe entry point to the Java Preferences API (java.util.prefs)
Groovy
3
star
12

thymeleaf-ifnotnull-dialect

A dialect that outputs elements and values only if the value exist
Groovy
2
star
13

thymeleaf-expression-processor

A simplified API for working with Thymeleaf expressions
Groovy
2
star
14

thymeleaf-testing-junit

A Thymeleaf Testing / JUnit bridge to treat each Thymeleaf test file as a JUnit test
Groovy
2
star
15

lesscss-filter

LessCSS filter/processor for Java web applications.
Java
2
star
16

yuicompressor-filter

YUI Compressor Filter for Java web applications.
Java
2
star
17

groovy-profiling-extensions

A collection of Groovy extensions to aid with profiling an application
Groovy
1
star
18

thymeleaf-joda-dialect

Adds Joda utility methods to Thymeleaf templates
Groovy
1
star
19

redux-utils

A collection of wrappers/utilities for common functions in redux
JavaScript
1
star
20

thymeleaf-template-servlet

Standalone servlet for serving Thymeleaf templates
Groovy
1
star
21

groovy-extensions

A collection of extensions for Groovy projects that I almost wish were a part of the GDK
Groovy
1
star
22

object-utils

A collection of utilities for JavaScript objects
JavaScript
1
star
23

thymeleaf-presentation

Demo project for the Thymeleaf presentation I did at SpringOne2GX 2013
Java
1
star
24

rss-xml-generator

Generate an XML document for an RSS feed
Groovy
1
star
25

eslint-config-ultraq

ESLint config for all of my JavaScript projects
1
star
26

dumb-query-selector

Shortcuts to the querySelector(All) functions, the (All) instead returning an array of nodes (because NodeLists are dumb)
JavaScript
1
star