From: Kai Moritz
Date: Fri, 8 Jul 2016 16:31:26 +0000 (+0200)
Subject: Projekt-Seite erstellt: Velocity-Template - JSON über th:with weitergereicht
X-Git-Tag: tmp1~1
X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=7470f501ed0a5aba02d7740fe565b0bbc88b8acb;p=maven-thymeleaf-skin
Projekt-Seite erstellt: Velocity-Template - JSON über th:with weitergereicht
Da die definierten Variablen sonst erst zu spät zur Verfügung stehen, müssen
sie per th:with in das Layout-Template hereingereicht und dort mit
juplo:variables verarbeitet werden.
---
diff --git a/src/site/site.xml b/src/site/site.xml
index ce59948..c89b14c 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -12,7 +12,7 @@
/simple-mapper/
- {"uri":"/projects.html","name":"Projects"},{"uri":"/simple-mapper/index.html","name":"Simple Mapper 4 JSON"}
+ {"uri":"/projects.html","name":"Projects"},{"uri":"/simple-mapper/index.html","name":"Simple Mapper 4 JSON"}
diff --git a/src/site/template.vm b/src/site/template.vm
index 8295340..f7e6c8b 100644
--- a/src/site/template.vm
+++ b/src/site/template.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