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

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: https://github.com/ultraq/thymeleaf-layout-dialect

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.

Releases

  • 2.0.0 - July 09, 2016 09:58
  • 1.4.0 - May 04, 2016 23:20
  • 1.3.3 - February 21, 2016 09:05
  • 1.3.2 - February 14, 2016 05:08
  • 1.3.1 - October 01, 2015 07:44
  • 1.3.0 - September 01, 2015 14:37
  • 1.2.9 - June 24, 2015 07:36
  • 1.2.8 - April 13, 2015 02:19
  • 1.2.7 - October 17, 2014 23:32
  • 1.2.6 - October 09, 2014 08:38
See all 21 releases

Project Statistics

SourceRank 14
Dependent repositories 397
Total releases 21
Latest release
First release
Stars 326
Forks 65
Watchers 51
Contributors 7
Repo Size: 2.88 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: 2016-07-18 11:41:53 UTC

Login to resync this project