<#-- dump.ftl -- -- Generates tree representations of data model items. -- -- Usage: -- <#import "dump.ftl" as dumper> -- -- <#assign foo = something.in["your"].data[0].model /> -- -- <@dumper.dump foo /> -- -- When used within html pages you've to use
-tags to get the wanted
  -- result:
  -- 
  -- <@dumper.dump foo />
  -- 
  -->
 
<#-- The black_list contains bad hash keys. Any hash key which matches a 
  -- black_list entry is prevented from being displayed.
  -->
<#assign black_list = ["class", "request", "getreader", "getinputstream", "writer"] />
 
 
<#-- 
  -- The main macro.
  -->
  
<#macro dump key data>
<#if data?is_enumerable>

${key} <@printList data,[] /> <#elseif data?is_hash_ex>

${key} <@printHashEx data,[] /> <#else>

<@printItem data?if_exists,[], key, false /> <#-- private helper macros. it's not recommended to use these macros from -- outside the macro library. --> <#macro printList list has_next_array> <#local counter=0 /> <#list list as item> <#list has_next_array+[true] as has_next><#if !has_next> <#else> | <#list has_next_array as has_next><#if !has_next> <#else> | <#t> <#t><@printItem item?if_exists,has_next_array+[item_has_next], counter, false /> <#local counter = counter + 1/> <#macro printHashEx hash has_next_array> = ${(hash.data!(hash.toString()))!"No String Representation"}

    Callable methods:
      <#list hash?keys as key> <#list has_next_array+[true] as has_next><#if !has_next> <#else> | <#list has_next_array as has_next><#if !has_next> <#else> | <#t> ${key}
<#macro printHashExFull hash has_next_array> <#list hash?keys as key> <#list has_next_array+[true] as has_next><#if !has_next> <#else> | <#list has_next_array as has_next><#if !has_next> <#else> | <#t> <#t><@printItem hash[key]?if_exists,has_next_array+[key_has_next], key, true /> <#macro printItem item has_next_array key full> <#if item?is_method> +- ${key} = ?? (method) <#elseif item?is_enumerable> +- ${key} <@printList item, has_next_array /><#t> <#elseif item?is_hash_ex && omit(key?string)><#-- omit bean-wrapped java.lang.Class objects --> +- ${key} (omitted) <#elseif item?is_hash_ex> +- ${key} <#if full> <@printHashExFull item, has_next_array /><#t> <#else> <@printHashEx item, has_next_array /><#t> <#elseif item?is_number> +- ${key} = ${item} <#elseif item?is_string> +- ${key} = "${item}" <#elseif item?is_boolean> +- ${key} = ${item?string} <#elseif item?is_date> +- ${key} = ${item?string("yyyy-MM-dd HH:mm:ss zzzz")} <#elseif item?is_transform> +- ${key} = ?? (transform) <#elseif item?is_macro> +- ${key} = ?? (macro) <#elseif item?is_hash> +- ${key} = ?? (hash) <#elseif item?is_node> +- ${key} = ?? (node) <#function omit key> <#local what = key?lower_case> <#list black_list as item> <#if what?index_of(item) gte 0> <#return true> <#return false>

All Liferay Variables

See the bottom for the request variable expansion
<#list .data_model?keys as var> <#if var?index_of("writer") lt 0> <@dump var,.data_model[var] />

The request object