Velocimacro - Generate a HTML Select box and its Options
A quick and simple Velocimacro to generate HTML Select boxes and its Options; automatically selects the correct option based on the value given. You can place this #macro anywhere in your Velocity templates but I used my global VM_global_library.vm file. Code ``` #macro( generateSelectBox $name $options $value ) #foreach ( $option in $options ) #set( $selected = "" ) #if ( $option == $value ) #set( $selected = "selected='true'" ) #end $option #end #end ``` Example Usage ``` #generateSelectBox( "enabled" ["Y","N"] $form.enabled ) ``` The resulting HTML: ``` Y N ``` Addendum 11th November 2005 : Thanks to MATT for pointing out the FreeMarker template engine as a promising replacement for Velocity. ;)
$ subscribe --newsletter
Practical AI engineering, in your inbox
Field notes for technical leaders building agents, evaluation systems, governance, and production infrastructure.
Related
What I Need Before I Approve an Agent’s Work
A review bundle should connect the requirement to evidence for the exact candidate and make the remaining decision explicit.
Giving an Agent an Inbox Without Giving It Your Mailbox
A dedicated email address limits which messages reach an agent; the harder details are untrusted content, sending authority and missing attachments.
Your Webhook Returned 200. Did the Work Happen?
Tracing a WHOOP event through receipt, diagnostic capture, Sheets forwarding and reconciliation reveals what a successful response leaves unproved.