NIHVIVO-2479 Continue work on dump templates for values of different types

This commit is contained in:
ryounes 2011-04-22 15:49:07 +00:00
parent 7b9bd45ad5
commit 62e6f0a3d6

View file

@ -24,15 +24,14 @@ div.dump {
margin-bottom: .25em; margin-bottom: .25em;
} }
.dump ul.sequence li.list_item { .dump ul li.item {
margin-bottom: 1.25em; margin-bottom: 1.25em;
} }
</style>
<#-- .dump ul li.item .value {
<#import "lib-dump.ftl" as dumper> margin-left: 1.5em;
<pre><@dumper.dump dump /></pre> }
--> </style>
<div class="dump"> <div class="dump">
<h3>${title}</h3> <h3>${title}</h3>
@ -45,10 +44,8 @@ div.dump {
<ul> <ul>
<#list dump?keys as key> <#list dump?keys as key>
<li> <li>
<#local dumpVal = dump[key] /> <p><strong>Variable name:</strong> ${key}</p>
<p><strong>Variable name:</strong> ${key}</p> <@doMap dump[key] />
<@doMap dumpVal />
</li> </li>
</#list> </#list>
</ul> </ul>
@ -64,53 +61,83 @@ div.dump {
</#if> </#if>
</#if> </#if>
<#if map.value?has_content> <#if map.type == "Directive" || map.type == "Method">
<div> <@doHelp map.help! />
<strong>Value:</strong> <#else>
<#local value = map.value> <@doValue map.type map.value! />
<#if value?is_string || value?is_number>${value}
<#elseif value?is_boolean>${value?string}
<#elseif value?is_date>${value?string("EEEE, MMMM dd, yyyy hh:mm:ss a zzz")}
<#-- At this point both types and collections have sequence values. We need to
reference the type of the original object to know whether it's indexable
or not. -->
<#elseif value?is_sequence><@doSequenceItems value map.type/>
<#elseif value?is_method || value?is_directive><@doMethod value />
<#elseif value?is_hash_ex><@doMapItems value />
<#else>
</#if>
</div>
</#if> </#if>
</#macro> </#macro>
<#macro doSequenceItems seq type> <#macro doValue type value="">
<div class="values">
<#if value??>
<#if value?is_sequence><@doSequenceValue value type/>
<#elseif value?is_hash_ex><@doMapValue value />
<#else><@doScalarValue type value />
</#if>
</#if>
</div>
</#macro>
<#macro doSequenceValue seq type>
<strong>Values:</strong>
<#if seq?has_content> <#if seq?has_content>
<ul class="sequence"> <ul class="sequence">
<#list seq as item> <#list seq as item>
<li class="list_item"> <li class="item">
<#if type == "Sequence">Item ${item_index}: </#if> <#if type == "Sequence">
<@doMap item /> Item ${item_index}:
<@valueDiv item />
<#else><@doMap item />
</#if>
</li> </li>
</#list> </#list>
</ul> </ul>
</#if> <#else>no values
</#if>
</#macro> </#macro>
<#macro doMapItems map> <#macro doMapValue map>
<strong>Values:</strong>
<#if map?has_content> <#if map?has_content>
<ul class="map"> <ul class="map">
<#list map?keys as key> <#list map?keys as key>
<li class="map_item"> <li class="item">
${key} => <@doMap map[key] /> ${key} => <@valueDiv map[key] />
</li> </li>
</#list> </#list>
</ul> </ul>
<#else>no values
</#if>
</#macro>
<#macro doScalarValue type value>
<strong>Value:</strong>
<#if value?is_string || value?is_number>${value}
<#elseif value?is_boolean>${value?string}
<#elseif value?is_date>${value?string("EEEE, MMMM dd, yyyy hh:mm:ss a zzz")}
<#else>no value
</#if>
</#macro>
<#macro doHelp help="">
<#if help?has_content>
<ul class="help">
<#list help?keys as key>
<li>
<p><strong>${key}</strong></p>
<#--<@valueDiv help[key] />-->
</li>
</#list>
</ul>
</#if> </#if>
</#macro> </#macro>
<#macro doMethod method> <#macro valueDiv value>
<div class="value"><@doMap value /></div>
</#macro> </#macro>
<#-- This will work after we move stylesheets to Configuration sharedVariables <#-- This will work after we move stylesheets to Configuration sharedVariables