The JSON is rendered in the page and picked up there by thymeleaf
[maven-thymeleaf-skin] / src / main / resources / META-INF / maven / site.vm
index 1e336ed..b81690c 100644 (file)
       uri='$sitePath$alignedFileName',
       title=~{:: title},
       maincontent=~{:: .maincontent},
-      json='MERGE:
-      {
-        "_titles": {
-          #set($sep = "")
-          #foreach($page in $pages)
-            $sep
-            "$sitePath$page.uri": "$page.name"
-            #set($sep = ",")
-          #end
-        },
-        "_childs": {
-          #set($sep = "")
-          #foreach($page in $pages)
-            #if(!$page.childs.isEmpty())
-              $sep
-              "$sitePath$page.uri": [
-                #set($csep = "")
-                #foreach($child in $page.childs.entrySet())
-                  $csep
-                  "$sitePath$child.key"
-                  #set($csep = ",")
-                #end
-              ]
-              #set($sep = ",")
-            #end
-          #end
-        },
-        "_crumbs": {
-          #set($sep = "")
-          #foreach($page in $pages)
-            $sep
-            "$sitePath$page.uri": [
-              #set($csep = "")
-              #if($siteCrumbs)
-                $siteCrumbs
-                #set($csep = ",")
-              #end
-              #set($last = "")
-              #foreach($crumb in $page.crumbs)
-                #if($sitePath+$crumb.uri != $last)
-                  $csep
-                  "$sitePath$crumb.uri"
-                  #set($csep = ",")
-                  #set($last = $sitePath+$crumb.uri)
-                #end
-              #end
-            ]
-            #set($sep = ",")
-          #end
-        }
-      }
-      ')}"
-    >
+      json='MERGE:' + ~{:: pre[class='json']/text()})}" >
   <head>
     <title id="title">#if($shortTitle and $shortTitle != '')$title#else$project.name &mdash; $pages.get($alignedFileName).name#end</title>
     <meta http-equiv="Content-Type" content="text/html; charset=${outputEncoding}" />
       $bodyContent
     </article>
     <hr />
-    <h2>Pages</h2>
+    <h2>Page Structure as JSON</h2>
+    <pre class="json">
+{
+  "_titles": {#set($sep = "")#foreach($page in $pages)$sep
+    "$sitePath$page.uri": "$page.name"#set($sep = ",")
+#end
+
+  },
+  "_childs": {#set($sep = "")#foreach($page in $pages)#if(!$page.childs.isEmpty())$sep
+    "$sitePath$page.uri": [#set($csep = "")#foreach($child in $page.childs.entrySet())$csep
+      "$sitePath$child.key"#set($csep = ",")#end
+
+    ]#set($sep = ",")#end#end
+
+  },
+  "_crumbs": {#set($sep = "")#foreach($page in $pages)$sep
+    "$sitePath$page.uri": [
+#set($csep = "")#if($siteCrumbs)
+      $siteCrumbs#set($csep = ",")#end#set($last = "")#foreach($crumb in $page.crumbs)#if($sitePath+$crumb.uri != $last)$csep
+      "$sitePath$crumb.uri"#set($csep = ",")#set($last = $sitePath+$crumb.uri)#end#end
+
+    ]#set($sep = ",")#end
+
+  }
+}
+    </pre>
+    <h2>All Pages</h2>
     <p>
       <ul>
         #foreach($page in $pages)<li><a href="$page.uri">$page.name</a></li>#end