NIHVIVO-564 Dump directive
This commit is contained in:
parent
5359909ae7
commit
e6a65f5ad0
7 changed files with 29 additions and 7 deletions
|
@ -69,6 +69,13 @@ public class TestController extends FreemarkerHttpServlet {
|
|||
body.put("zoo1", zoo1);
|
||||
body.put("zoo2", zoo2);
|
||||
|
||||
// Test recursive dump - array of arrays
|
||||
// String[] fruitArray = { "apples", "bananas", "strawberries" };
|
||||
// String[] animalArray = { "cat", "dog", "mouse" };
|
||||
// String[] dayArray = { "Monday", "Tuesday", "Wednesday" };
|
||||
// String[][] arrays = { fruitArray, animalArray, dayArray };
|
||||
// body.put("arrays", arrays);
|
||||
|
||||
body.put("trueStatement", true);
|
||||
body.put("falseStatement", false);
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ public class DumpDirective implements TemplateDirectiveModel {
|
|||
String includeTemplate;
|
||||
Object value = val;
|
||||
String type = null;
|
||||
Writer out = env.getOut();
|
||||
|
||||
if (val instanceof SimpleScalar) {
|
||||
includeTemplate = "dump-string.ftl";
|
||||
|
@ -70,6 +71,10 @@ public class DumpDirective implements TemplateDirectiveModel {
|
|||
includeTemplate = "dump-array.ftl";
|
||||
} else if (val instanceof SimpleHash) {
|
||||
includeTemplate = "dump-hash.ftl";
|
||||
// In recursive dump, we've gotten down to a raw string
|
||||
// } else if (val == null) {
|
||||
// out.write(var);
|
||||
// return;
|
||||
} else {
|
||||
includeTemplate = "dump-string.ftl";
|
||||
value = value.toString();
|
||||
|
@ -83,11 +88,11 @@ public class DumpDirective implements TemplateDirectiveModel {
|
|||
map.put("type", type);
|
||||
|
||||
map.put("stylesheets", dataModel.get("stylesheets"));
|
||||
//map.put("dump", this);
|
||||
|
||||
FreemarkerHelper helper = new FreemarkerHelper();
|
||||
String output = helper.mergeMapToTemplate(templateName, map, config);
|
||||
|
||||
Writer out = env.getOut();
|
||||
out.write(output);
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
|
||||
.dump {
|
||||
border-top: 1px solid #ccc;
|
||||
border-bottom: 2px solid #ccc;
|
||||
border-bottom: 3px solid #ccc;
|
||||
padding: 1em 0;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.dump li {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
<strong>Values:</strong><br />
|
||||
<ul>
|
||||
<#list value as item>
|
||||
<#-- Shallow (non-recursive) dump -->
|
||||
<li>${item_index}: ${item}</li>
|
||||
<#-- Deep (recursive) dump
|
||||
<li>${item_index}: <@dump var="${item}" /></li> -->
|
||||
</#list>
|
||||
</ul>
|
|
@ -7,6 +7,9 @@
|
|||
|
||||
<ul>
|
||||
<#list value?keys as key>
|
||||
<#-- Shallow (non-recursive) dump -->
|
||||
<li>${key} = ${value[key]}</li>
|
||||
<#-- Deep (recursive) dump
|
||||
<li>${key} = <@dump var="${value[key]}" /></li> -->
|
||||
</#list>
|
||||
</ul>
|
|
@ -4,4 +4,3 @@
|
|||
|
||||
<strong>Type:</strong> ${type}<br />
|
||||
<strong>Value:</strong> ${value}<br />
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
<@dump var="fruit" />
|
||||
<@dump var="trueStatement" />
|
||||
<@dump var="falseStatement" />
|
||||
|
||||
<@dumpDataModel />
|
||||
|
||||
${stylesheets.addFromTheme("/sstest.css", "/sstest2.css")}
|
||||
|
|
Loading…
Add table
Reference in a new issue