NIHVIVO-564 Work on dump directive
This commit is contained in:
parent
83938a2c19
commit
b9ac586c20
5 changed files with 27 additions and 12 deletions
|
@ -11,6 +11,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHelper;
|
||||||
import freemarker.core.Environment;
|
import freemarker.core.Environment;
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
import freemarker.template.SimpleDate;
|
import freemarker.template.SimpleDate;
|
||||||
|
import freemarker.template.SimpleHash;
|
||||||
import freemarker.template.SimpleScalar;
|
import freemarker.template.SimpleScalar;
|
||||||
import freemarker.template.SimpleSequence;
|
import freemarker.template.SimpleSequence;
|
||||||
import freemarker.template.TemplateBooleanModel;
|
import freemarker.template.TemplateBooleanModel;
|
||||||
|
@ -66,7 +67,8 @@ public class DumpDirective implements TemplateDirectiveModel {
|
||||||
type = "boolean";
|
type = "boolean";
|
||||||
} else if (val instanceof SimpleSequence){
|
} else if (val instanceof SimpleSequence){
|
||||||
includeTemplate = "dump-array.ftl";
|
includeTemplate = "dump-array.ftl";
|
||||||
type = "array";
|
} else if (val instanceof SimpleHash) {
|
||||||
|
includeTemplate = "dump-hash.ftl";
|
||||||
} else {
|
} else {
|
||||||
includeTemplate = "dump-string.ftl";
|
includeTemplate = "dump-string.ftl";
|
||||||
value = value.toString();
|
value = value.toString();
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
<#-- Template for dumping string values -->
|
<#-- Template for dumping array values -->
|
||||||
|
|
||||||
|
<strong>Type:</strong> array<br />
|
||||||
|
<strong>Values:</strong><br />
|
||||||
<ul>
|
<ul>
|
||||||
<#list value as item>
|
<#list value as item>
|
||||||
<li>${item_index}: ${item}</li>
|
<li>${item_index}: ${item}</li>
|
||||||
</#list>
|
</#list>
|
||||||
</ul>
|
</ul>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Template for dumping hash values -->
|
||||||
|
|
||||||
|
<strong>Type:</strong> hash<br />
|
||||||
|
<strong>Values:</strong><br />
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<#list value?keys as key>
|
||||||
|
<li>${key} = ${value[key]}</li>
|
||||||
|
</#list>
|
||||||
|
</ul>
|
|
@ -2,5 +2,6 @@
|
||||||
|
|
||||||
<#-- Template for dumping string values -->
|
<#-- Template for dumping string values -->
|
||||||
|
|
||||||
${value}
|
<strong>Type:</strong> ${type}<br />
|
||||||
|
<strong>Value:</strong> ${value}<br />
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,14 @@
|
||||||
|
|
||||||
<#-- Template for dumping a template variable -->
|
<#-- Template for dumping a template variable -->
|
||||||
|
|
||||||
<hr />
|
<hr /> <#-- turn these into borders once css is working -->
|
||||||
<div class="dump">
|
<div class="dump">
|
||||||
|
|
||||||
<h6>Freemarker template variable dump</h6>
|
<h6>Freemarker template variable dump</h6>
|
||||||
|
|
||||||
<strong>Variable <em>${var}</em>:</strong><br/ >
|
<strong>Variable <em>${var}</em>:</strong><br/ >
|
||||||
<strong>Type:</strong> ${type}<br />
|
<#include includeTemplate />
|
||||||
<strong>Value:</strong>
|
|
||||||
<#include includeTemplate />
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr />
|
<hr /> <#-- turn these into borders once css is working -->
|
Loading…
Add table
Reference in a new issue