- Revision
- 611
- Author
- mauro
- Date
- 2008-04-14 06:45:12 -0500 (Mon, 14 Apr 2008)
Log Message
Moved ftl/waffle.ftl to ftl/waffle/form.ftl
Modified Paths
- trunk/examples/freemarker-example/src/main/webapp/people/editperson.htm
- trunk/examples/freemarker-example/src/main/webapp/people/person.htm
Added Paths
- trunk/waffle-resources/src/main/resources/ftl/waffle/
- trunk/waffle-resources/src/main/resources/ftl/waffle/form.ftl
Removed Paths
Diff
Modified: trunk/examples/freemarker-example/src/main/webapp/people/editperson.htm (610 => 611)
--- trunk/examples/freemarker-example/src/main/webapp/people/editperson.htm 2008-04-14 11:19:46 UTC (rev 610) +++ trunk/examples/freemarker-example/src/main/webapp/people/editperson.htm 2008-04-14 11:45:12 UTC (rev 611) @@ -1,4 +1,4 @@ -<#import "/ftl/waffle.ftl" as w> +<#import "/ftl/waffle/form.ftl" as w> <div class="editContainer" xmlns="http://www.w3.org/1999/xhtml"> <h3>Edit Person</h3>
Modified: trunk/examples/freemarker-example/src/main/webapp/people/person.htm (610 => 611)
--- trunk/examples/freemarker-example/src/main/webapp/people/person.htm 2008-04-14 11:19:46 UTC (rev 610) +++ trunk/examples/freemarker-example/src/main/webapp/people/person.htm 2008-04-14 11:45:12 UTC (rev 611) @@ -1,4 +1,4 @@ -<#import "/ftl/waffle.ftl" as w> +<#import "/ftl/waffle/form.ftl" as w> <?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml">
Added: trunk/waffle-resources/src/main/resources/ftl/waffle/form.ftl (0 => 611)
--- trunk/waffle-resources/src/main/resources/ftl/waffle/form.ftl (rev 0) +++ trunk/waffle-resources/src/main/resources/ftl/waffle/form.ftl 2008-04-14 11:45:12 UTC (rev 611) @@ -0,0 +1,84 @@ +<#ftl strip_whitespace=true> +<#-- + * A collection of FTL (Freemarker Template Language) functions and macros to use in HTML forms + * + * @author Mauro Talevi + --> + +<#-- + * Determines if list contains the item. + * + * @param list the list to search for the item + * @param item the item to search for in the list + * @return true if item is found in the list, false otherwise +--> +<#function contains list item> + <#list list as next> + <#if next == item><#return true></#if> + </#list> + <#return false> +</#function> + +<#-- + * Shows values as CSV + * + * @param values the sequence of values + --> +<#macro asCSV values> + <#list values as value>${value}<#if value_has_next>,</#if></#list> +</#macro> + +<#-- + * Show a select input element allowing a value to be chosen from a list of options. + * + * @param field the name of the field to bind the element to + * @param options a sequence of available options + * @param selectedValue the selected value (defaults to "") + * @param attributes any additional attributes for the element (defaults to "") +--> +<#macro selectSingle field options selectedValue="" attributes=""> + <select id="${field}" name="${field}" ${attributes}> + <#list options as value> + <option value="${value?html}"<@isSelected value selectedValue/>>${value?html}</option> + </#list> + </select> +</#macro> + +<#-- + * Show a select input element allowing a multiple values to be chosen from a list of options. + * + * @param field the name of the field to bind the element to + * @param options a sequence of available options + * @param selectedValues the selected values (defaults to [""]) + * @param attributes any additional attributes for the element (defaults to "") +--> +<#macro selectMultiple field options selectedValues attributes=""> + <select multiple="multiple" id="${field}" name="${field}" ${attributes}> + <#list options as value> + <#assign selected = contains(selectedValues?default([""]), value)> + <option value="${value?html}" <#if selected>selected="true"</#if>>${value?html}</option> + </#list> + </select> +</#macro> + +<#-- + * Determines if a value in a sequence is selected, adding the 'selected' attribute if so. + * + * @param currentValue the current value in a sequence + * @param value the value to check +--> +<#macro isSelected currentValue value> + <#if currentValue?is_number && currentValue == value?number>selected="true"</#if> + <#if currentValue?is_string && currentValue == value>selected="true"</#if> +</#macro> + +<#-- + * Determines if values in a sequence are selected, adding the 'selected' attribute if so. + * + * @param currentValue the current value in a sequence + * @param values the values to check +--> +<#macro areSelected currentValue values> + <#assign selected = contains(values?default([""]), currentValue)> + <#if selected>selected="true"</#if>> +</#macro>
Deleted: trunk/waffle-resources/src/main/resources/ftl/waffle.ftl (610 => 611)
--- trunk/waffle-resources/src/main/resources/ftl/waffle.ftl 2008-04-14 11:19:46 UTC (rev 610) +++ trunk/waffle-resources/src/main/resources/ftl/waffle.ftl 2008-04-14 11:45:12 UTC (rev 611) @@ -1,84 +0,0 @@ -<#ftl strip_whitespace=true> -<#-- - * A collection of FTL (Freemarker Template Language) functions and macros for use in Waffle web applications - * - * @author Mauro Talevi - --> - -<#-- - * Determines if list contains the item. - * - * @param list the list to search for the item - * @param item the item to search for in the list - * @return true if item is found in the list, false otherwise ---> -<#function contains list item> - <#list list as next> - <#if next == item><#return true></#if> - </#list> - <#return false> -</#function> - -<#-- - * Shows values as CSV - * - * @param values the sequence of values - --> -<#macro asCSV values> - <#list values as value>${value}<#if value_has_next>,</#if></#list> -</#macro> - -<#-- - * Show a select input element allowing a value to be chosen from a list of options. - * - * @param field the name of the field to bind the element to - * @param options a sequence of available options - * @param selectedValue the selected value (defaults to "") - * @param attributes any additional attributes for the element (defaults to "") ---> -<#macro selectSingle field options selectedValue="" attributes=""> - <select id="${field}" name="${field}" ${attributes}> - <#list options as value> - <option value="${value?html}"<@isSelected value selectedValue/>>${value?html}</option> - </#list> - </select> -</#macro> - -<#-- - * Show a select input element allowing a multiple values to be chosen from a list of options. - * - * @param field the name of the field to bind the element to - * @param options a sequence of available options - * @param selectedValues the selected values (defaults to [""]) - * @param attributes any additional attributes for the element (defaults to "") ---> -<#macro selectMultiple field options selectedValues attributes=""> - <select multiple="multiple" id="${field}" name="${field}" ${attributes}> - <#list options as value> - <#assign selected = contains(selectedValues?default([""]), value)> - <option value="${value?html}" <#if selected>selected="true"</#if>>${value?html}</option> - </#list> - </select> -</#macro> - -<#-- - * Determines if a value in a sequence is selected, adding the 'selected' attribute if so. - * - * @param currentValue the current value in a sequence - * @param value the value to check ---> -<#macro isSelected currentValue value> - <#if currentValue?is_number && currentValue == value?number>selected="true"</#if> - <#if currentValue?is_string && currentValue == value>selected="true"</#if> -</#macro> - -<#-- - * Determines if values in a sequence are selected, adding the 'selected' attribute if so. - * - * @param currentValue the current value in a sequence - * @param values the values to check ---> -<#macro areSelected currentValue values> - <#assign selected = contains(values?default([""]), currentValue)> - <#if selected>selected="true"</#if>> -</#macro>
To unsubscribe from this list please visit:
