nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect 2.2.1

A dialect for Thymeleaf that allows you to use layout/decorator templates to style your content.

Homepage: http://www.ultraq.net.nz/programming/thymeleaf-layout-dialect/

Platform: Maven

Language: Groovy

License: Apache-2.0

Repository: scm:git:[email protected]:ultraq/thymeleaf-layout-dialect.git

View on registry: http://search.maven.org/#artifactdetails%7Cnz.net.ultraq.thymeleaf%...


Thymeleaf Layout Dialect

Build Status GitHub Release Maven Central License

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

If you've ever used SiteMesh for your JSPs, or Facelets with JSFs, then the concepts of this library will be very familiar to you.

Docs

For installation instructions, examples, and configuration options, check out the docs pages over on https://ultraq.github.io/thymeleaf-layout-dialect/

Upgrading an existing project to Thymeleaf 3 and layout dialect 2? Then give the migration guide a read.

TL;DR

Create a common layout to be used for several pages, defining extension points in the body with the layout:fragment/data-layout-fragment processors:

<!DOCTYPE html>
<html>
<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>
  <footer>
    <p>My footer</p>
    <p layout:fragment="custom-footer">Custom footer here</p>
  </footer>  
</body>
</html>

Create a content page that will use the layout, defining any HTML to use for the extension points in the layout, and specified by a layout:decorate/data-layout-decorate processor at the root element of your page:

<html 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>
  <footer>
    <p layout:fragment="custom-footer">This is some footer content from the content page</p>
  </footer>
</body>
</html>

Get Thymeleaf to process your content page. The result will be the layout template decorated by your content page, meaning that the content page will fill out the layout's extension points, replace titles, and merge <head> items:

<!DOCTYPE html>
<html>
<head>
  <title>Content page 1</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 content page 1</p>
  </section>
  <footer>
    <p>My footer</p>
    <p>This is some footer content from content page 1</p>
  </footer>  
</body>
</html>

Intrigued? Check out the documentation links near the top of this readme to learn more.

Sustain

Releases

2.2.1 March 11, 2017
2.2.0 February 19, 2017
2.1.2 November 30, 2016
2.1.1 November 10, 2016
2.1.0 November 06, 2016
2.0.5 October 22, 2016
2.0.4 October 01, 2016
2.0.3 September 18, 2016
2.0.2 September 17, 2016
2.0.1 July 21, 2016
See all 31 releases

Project Statistics

SourceRank 17
Dependencies 0
Dependent projects 4
Dependent repositories 489
Total releases 31
Latest release
First release
Stars 344
Forks 66
Watchers 49
Contributors 7
Repo Size: 2.9 MB

Top Contributors See all

Emanuel Rabina zhanhb Justin Munn Brian Clozel Oliver Niekrenz Michael Stummvoll David M. Carr

Something wrong with this page? Make a suggestion

Export .ABOUT file for this library

Last synced: 2017-05-02 09:48:31 UTC

Login to resync this project