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,7 +54,8 @@ 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";
|
||||
type = "string";
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue