Skip to content

Instantly share code, notes, and snippets.

@lynas
Created July 10, 2016 04:05
Show Gist options
  • Save lynas/2333db0e0534b6f82869ad6369365d52 to your computer and use it in GitHub Desktop.
Save lynas/2333db0e0534b6f82869ad6369365d52 to your computer and use it in GitHub Desktop.
thymeleaf template
// this is the layout. Lets asume file name is given layoutRoot.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
</head>
<body>
<header>
Head Section
</header>
<div layout:fragment="page-content">
Page content
</div>
<footer class="page-footer">
</footer>
</body>
</html>
// this is all the pages that are going to get the top layout
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:data="https://github.com/mxab/thymeleaf-extras-data-attribute"
layout:decorator="layoutRoot"
lang="en">
<body>
<div layout:fragment="page-content">
page items
</div>
</body>
</html>
// put both file in webapp folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment