Last active
December 14, 2021 13:50
-
-
Save topolik/f8b25bd952b40cce268d34ea0143df4b to your computer and use it in GitHub Desktop.
freemarker dump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[#assign recursionDepth=1 /] | |
<b>Namespace vars</b> | |
<pre> | |
.main | |
===== | |
[@listnamespace namespaceName=".main" /] | |
</pre> | |
<b>Model .data_model</b> | |
============= | |
[@recurseModel ".data_model" recursionDepth /] | |
[#macro listnamespace namespaceName] | |
[#list (namespaceName?eval)?keys as var] | |
[#if (namespaceName?eval)[var]?is_sequence] | |
${var}: | |
[#list (namespaceName?eval)[var] as varkey] | |
${varkey}, | |
[/#list] | |
[#elseif (namespaceName?eval)[var]?is_macro] | |
${var}: macro | |
[#elseif (namespaceName?eval)[var]?is_hash] | |
===${var}=== | |
[@listnamespace namespaceName="${var}" /] | |
===/${var}=== | |
[#elseif (namespaceName?eval)[var]?is_boolean] | |
${var}: ${(namespaceName?eval)[var]?string("TRUE","FALSE")} | |
[#else] | |
${var}: ${(namespaceName?eval)[var]} | |
[/#if] | |
[/#list] | |
[/#macro] | |
[#macro recurseModel varName depth] | |
[#if now??] | |
[#assign now = now + {"${varName}": .now?long} /] | |
[#else] | |
[#assign now = {"${varName}": .now?long} /] | |
[/#if] | |
[#attempt] | |
[#if varName?contains("writer") || varName?contains("Writer") || varName?contains("stream") || varName?contains("Stream")] | |
<i>(skipping inspection of writer / stream)</i> | |
[#elseif (depth == 0)] | |
[#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content] ${(varName?eval)?xhtml} | |
[#elseif (varName?eval)?? && (varName?eval)?is_macro] <i>(...macro/function)</i> [#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content] ${(varName?eval)?xhtml}[/#if] | |
[#elseif (varName?eval)?? && (varName?eval)?is_method] <i>(...method())</i> [#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content] ${(varName?eval)?xhtml}[/#if] | |
[/#if] | |
<i>(Reached depth ${depth})</i> | |
[#else] | |
[#if false] | |
[#elseif (varName?eval)?? && (varName?eval)?is_macro] <i>(...macro/function)</i> [#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content] ${(varName?eval)?xhtml}[/#if] | |
[#elseif (varName?eval)?? && (varName?eval)?is_method] <i>(...method())</i> [#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content] ${(varName?eval)?xhtml}[/#if] | |
[#elseif (varName?eval)?? && (varName?eval)?is_sequence] | |
<ol> | |
[#assign idx=0 /] | |
[#list (varName?eval) as row] | |
<li title='${varName}["${idx}"]'>[@recurseModel varName+"["+idx+"]" depth-1 /]</li> | |
[#assign idx=idx+1 /] | |
[/#list] | |
</ol> | |
[#elseif (varName?eval)?? && (varName?eval)?has_content] | |
[#if (varName?eval)?is_number] ${(varName?eval)?c} | |
[#elseif (varName?eval)?is_date] ${(varName?eval)?date} | |
[#elseif (varName?eval)?is_boolean] ${(varName?eval)?string("TRUE","FALSE")} | |
[#elseif (varName?eval)?is_hash_ex] | |
[#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content] ${(varName?eval)?xhtml}[/#if] | |
<ul> | |
[#list (varName?eval)?keys as varkey] | |
[#assign sanitizedKey=(varkey + "")?replace("\\","\\\\","i")?replace("\"","\\\"","i") /] | |
[#assign newVarName=varName+"[\""+sanitizedKey+"\"]" /] | |
<li title='${varName}["${sanitizedKey}"]'> ${varkey} -> [@recurseModel newVarName depth-1 /] </li> | |
[/#list] | |
</ul> | |
[#elseif (varName?eval)?is_hash] <i>( ...hash)</i> [#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content] ${(varName?eval)?xhtml}[/#if] | |
[#elseif (varName?eval)?is_string] ${(varName?eval)?xhtml} | |
[#else] <i>(... unknown type)</i> | |
[/#if] | |
[#else] <i>(... empty )</i> | |
[/#if] | |
[/#if] | |
[#recover]<i>(... unable to resolve ${varName})</i>[/#attempt] | |
<b>Time: ${.now?long - now["${varName}"]}</b> | |
[/#macro] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#assign recursionDepth=1 /> | |
<b>Namespace vars</b> | |
<pre> | |
.main | |
===== | |
<@listnamespace namespaceName=".main" /> | |
</pre> | |
<b>Model .data_model</b> | |
============= | |
<@recurseModel ".data_model" recursionDepth /> | |
<#macro listnamespace namespaceName> | |
<#list (namespaceName?eval)?keys as var> | |
<#if (namespaceName?eval)[var]?is_sequence> | |
${var}: | |
<#list (namespaceName?eval)[var] as varkey> | |
${varkey}, | |
</#list> | |
<#elseif (namespaceName?eval)[var]?is_macro> | |
${var}: macro | |
<#elseif (namespaceName?eval)[var]?is_hash> | |
===${var}=== | |
<@listnamespace namespaceName="${var}" /> | |
===/${var}=== | |
<#elseif (namespaceName?eval)[var]?is_boolean> | |
${var}: ${(namespaceName?eval)[var]?string("TRUE","FALSE")} | |
<#else> | |
${var}: ${(namespaceName?eval)[var]} | |
</#if> | |
</#list> | |
</#macro> | |
<#macro recurseModel varName depth> | |
<#if now??> | |
<#assign now = now + {"${varName}": .now?long} /> | |
<#else> | |
<#assign now = {"${varName}": .now?long} /> | |
</#if> | |
<#attempt> | |
<#if varName?contains("writer") || varName?contains("Writer") || varName?contains("stream") || varName?contains("Stream")> | |
<i>(skipping inspection of writer / stream)</i> | |
<#elseif (depth == 0)> | |
<#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content> ${(varName?eval)?xhtml} | |
<#elseif (varName?eval)?? && (varName?eval)?is_macro> <i>(...macro/function)</i> <#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content> ${(varName?eval)?xhtml}</#if> | |
<#elseif (varName?eval)?? && (varName?eval)?is_method> <i>(...method())</i> <#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content> ${(varName?eval)?xhtml}</#if> | |
</#if> | |
<i>(Reached depth ${depth})</i> | |
<#else> | |
<#if false> | |
<#elseif (varName?eval)?? && (varName?eval)?is_macro> <i>(...macro/function)</i> <#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content> ${(varName?eval)?xhtml}</#if> | |
<#elseif (varName?eval)?? && (varName?eval)?is_method> <i>(...method())</i> <#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content> ${(varName?eval)?xhtml}</#if> | |
<#elseif (varName?eval)?? && (varName?eval)?is_sequence> | |
<ol> | |
<#assign idx=0 /> | |
<#list (varName?eval) as row> | |
<li title='${varName}["${idx}"]'><@recurseModel varName+"["+idx+"]" depth-1 /></li> | |
<#assign idx=idx+1 /> | |
</#list> | |
</ol> | |
<#elseif (varName?eval)?? && (varName?eval)?has_content> | |
<#if (varName?eval)?is_number> ${(varName?eval)?c} | |
<#elseif (varName?eval)?is_date> ${(varName?eval)?date} | |
<#elseif (varName?eval)?is_boolean> ${(varName?eval)?string("TRUE","FALSE")} | |
<#elseif (varName?eval)?is_hash_ex> | |
<#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content> ${(varName?eval)?xhtml}</#if> | |
<ul> | |
<#list (varName?eval)?keys as varkey> | |
<#assign sanitizedKey=(varkey + "")?replace("\\","\\\\","i")?replace("\"","\\\"","i") /> | |
<#assign newVarName=varName+"[\""+sanitizedKey+"\"]" /> | |
<li title='${varName}["${sanitizedKey}"]'> ${varkey} -> <@recurseModel newVarName depth-1 /> </li> | |
</#list> | |
</ul> | |
<#elseif (varName?eval)?is_hash> <i>( ...hash)</i> <#if (varName?eval)?? && (varName?eval)?is_string && (varName?eval)?has_content> ${(varName?eval)?xhtml}</#if> | |
<#elseif (varName?eval)?is_string> ${(varName?eval)?xhtml} | |
<#else> <i>(... unknown type)</i> | |
</#if> | |
<#else> <i>(... empty )</i> | |
</#if> | |
</#if> | |
<#recover><i>(... unable to resolve ${varName})</i></#attempt> | |
<b>Time: ${.now?long - now["${varName}"]}</b> | |
</#macro> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fragments where double ampersands don't work, using nested ifs.