NIHVIVO-564 Dump directive

This commit is contained in:
rjy7 2010-07-28 17:48:03 +00:00
parent 5359909ae7
commit e6a65f5ad0
7 changed files with 29 additions and 7 deletions

View file

@ -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);

View file

@ -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);
}