simple_test.ftl
File header- Author
- Luis Panadero
- Author
- Other guy
- Copyright
- bla bla bla 2021
Macro and Function Summary
no category
macro
|
|
macro
|
|
macro
|
|
macro
|
|
macro
|
|
macro carry_atribs
vars
exclude
Macro to generate HTML attributes from a hash containing <AttributeName : Value> Attribute names are normalized, replacing '_' by '-'
Name | Type | Description |
---|---|---|
vars |
Hash | Map with pairs of attribute name - value |
exclude |
(Optional) A list of attributes to be ignored |
<#macro carry_atribs vars exclude=[]>
<@compress single_line=true>
<#if vars?is_sequence><#return /></#if>
<#list vars?keys as k>
<#if !exclude?seq_contains(k) && (k != "temp")
&& (k != "data") && (k != "attrs") && (k != "dynattrs") && (k != "aria")>
<#if vars[k]?is_sequence>
<#if vars[k]?size > 0><#t>
${k?replace('_', '-')}="<#list vars[k] as temp><#t>
<#if temp != ""><#t>
<#if temp?is_number || temp?is_boolean ><#local temp=temp?c /></#if>${temp} <#t>
</#if><#t>
</#list> " </#if>
<#else>
<#if vars[k]?is_number || vars[k]?is_boolean ><#local temp=vars[k]?c /><#t>
<#else><#local temp = vars[k]?string /><#t>
</#if> <#if temp != "">
${k?replace('_', '-')}="${temp}"
</#if>
</#if>
</#if>
</#list>
</@compress>
</#macro>
macro data_atribs
data
Macro to generate data-XXX HTML attributes
Name | Type | Description |
---|---|---|
data |
Hash<String,String> | Map with pairs of XXX field - value |
<#macro data_atribs data={}>
<#if data?is_hash>
<#list data as key, value>
<#if value?is_number || value?is_boolean><#local temp=value?c /><#else><#local temp=value?string /></#if>
data-${key}="${temp}"
</#list>
</#if>
</#macro>
macro fooBar2000
foo
baz
Macro without category
Name | Type | Description |
---|---|---|
foo |
String | A foo string |
baz |
Sequence | (Optional) A list of baz things |
<#macro fooBar2000 foo baz=[]>
FooBar2000 ${foo!}
<#list baz as ba>
${ba}
</#list>
</#macro>
macro putOnArray
arrayVar
content
Macro that put a value on a array
Name | Type | Description |
---|---|---|
arrayVar |
String | Variable name that must be a sequence |
content |
(Optional)
Content to be appened to the array pointer by arrayVar
Default value : "" |
<#macro putOnArray arrayVar content="">
<#if content?is_string && content == "">
<#local content>
<#nested />
</#local>
</#if>
<#-- freemarker doing some metaprogramming -->
<#if content?is_string>
<@"<#assign ${arrayVar} = (${arrayVar}![]) + [content]>"?interpret />
<#elseif content?is_enumerable>
<@"<#assign ${arrayVar} = (${arrayVar}![]) + content>"?interpret />
</#if>
</#macro>