FreeMarker: Switch-Case Test

Here we iterate over a list of animals.

<#assign animalList = [ "aardvark", "kiwi", "gecko", "cat", "dog", "elephant", "squirrel", "zebra" ]> <#assign favoriteAnimal = "kiwi"> <#foreach animal in animalList>

Animal is: ${animal}.
<#switch animal> <#case "zebra"> This is the HTML for a large stripey animal. <#case "elephant"> <#case "rhinocerous"> This is the HTML for large animals. <#break> <#case "squirrel"> <#case "gecko"> This is the HTML for small animals. <#break> <#case favoriteAnimal> This is the HTML for the user's favorite animal. <#break> <#default> This is the HTML for other animals. <#break>