AnsweredAssumed Answered

Freemarker template that dumps all properties for a node

Question asked by pmonks on Jan 28, 2010
Latest reply on Mar 15, 2010 by tommorris
G'day everyone,

I wrote this code some time ago and thought someone might find it useful - it's a Freemarker template that dumps all of the metadata properties for a node.  Currently it's setup to be configured as a Custom View for a document or space (ie. it's an Explorer UI Presentation Template), but it can be readily adapted for use in other Freemarker templates (eg. in a Web Script view) by copying just the macro.

<#macro dumpProperties node>
  <#if node.properties??>
  <table>
    <#list node.properties?keys as key>
    <#assign value = node.properties[key]>
    <tr>
      <td>${key}</td>
      <td>
      <#if value?is_date>
        ${value?datetime}
      <#elseif value?is_sequence>
        [
        <#list value as valueValue>
          ${valueValue},
        </#list>
        ]
      <#else>
         ${value}
      </#if>
      </td>
    </tr>
    </#list>
  </table>
  <#else>
    Node doesn't have properties.
  </#if>
</#macro>

<#if space??>
<strong>Properties for 'space':</strong>
<blockquote>
<@dumpProperties space/>
</blockquote>
</#if>

<#if person??>
<strong>Properties for 'person':</strong>
<blockquote>
<@dumpProperties person/>
</blockquote>
</#if>

<#if document??>
<strong>Properties for 'document':</strong>
<blockquote>
<@dumpProperties document/>
</blockquote>
</#if>

<#if companyHome??>
<strong>Properties for 'companyHome':</strong>
<blockquote>
<@dumpProperties companyHome/>
</blockquote>
</#if>

Note: currently it doesn't dump associations (either parent-child or peer-to-peer), but that would be a trivial enhancement.

Please reply to this thread if you have any questions / comments / suggestions / improvements / etc.

Cheers,
Peter

Outcomes