From 23d828ee5b1f217f984cf27e750b5a4d26472b9a Mon Sep 17 00:00:00 2001
From: Kai Moritz
Date: Fri, 8 Jul 2016 18:31:26 +0200
Subject: [PATCH] JSON is handed to the thymeleaf-layout-template via th:with
The page-data is handed to the template via th:with als variable "json".
---
src/main/resources/META-INF/maven/site.vm | 7 +++++--
src/site/site.xml | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/main/resources/META-INF/maven/site.vm b/src/main/resources/META-INF/maven/site.vm
index 8295340..f7e6c8b 100644
--- a/src/main/resources/META-INF/maven/site.vm
+++ b/src/main/resources/META-INF/maven/site.vm
@@ -115,7 +115,10 @@
xmlns="http://www.w3.org/1999/xhtml"
xmlns:layout="http://www.thymeleaf.org"
layout:decorator="templates/layout"
- th:with="uri='$sitePath$alignedFileName'"
+ th:with="
+ uri='$sitePath$alignedFileName',
+ json='merge:{"pages":{#set($sep = "")#foreach($page in $pages)$sep"$sitePath$page.uri":{"name":"$page.name",#if(!$page.childs.isEmpty())"childs":{#set($csep = "")#foreach($child in $page.childs.entrySet())$csep"$sitePath$child.key":"$child.value"#set($csep = ",")#end},#end"crumbs":[#set($csep = "")#if($siteCrumbs)$siteCrumbs#set($csep = ",")#end#foreach($crumb in $page.crumbs)$csep{"uri":"$sitePath$crumb.uri","name":"$crumb.name"}#set($csep = ",")#end]#if($page.title),"title":"$page.title"#end#if($page.alt),"alt":"$page.alt"#end#if($page.img),"img":"$page.img"#end}#set($sep = ",")#end}#if($siteTitle),"site_title":"$siteTitle"#end#if($siteAlt),"site_alt":"$siteAlt"#end#if($siteImg),"site_img":"$siteImg"#end}'
+ "
>
juplo - $title
@@ -130,7 +133,7 @@
-
+
$bodyContent
diff --git a/src/site/site.xml b/src/site/site.xml
index 4ac76eb..015e0b3 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -24,7 +24,7 @@
/maven-thymeleaf-skin/
- {"uri":"/projects.html","name":"Projects"},{"uri":"/maven-thymeleaf-skin/index.html","name":"Apache-Maven Thymeleaf-Skin"}
+ {"uri":"/projects.html","name":"Projects"},{"uri":"/maven-thymeleaf-skin/index.html","name":"Apache-Maven Thymeleaf-Skin"}
--
2.20.1