soy_template.soy 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Greets a person using "Hello" by default.
  3. * @param name The name of the person.
  4. * @param? greetingWord Optional greeting word to use instead of "Hello".
  5. */
  6. {template .helloName #eee}
  7. {if not $greetingWord}
  8. Hello {$name}!
  9. {else}
  10. {$greetingWord} {$name}!
  11. {/if}
  12. {/template}
  13. /**
  14. * Greets a person and optionally a list of other people.
  15. * @param name The name of the person.
  16. * @param additionalNames The additional names to greet. May be an empty list.
  17. */
  18. {template .helloNames}
  19. // Greet the person.
  20. {call .helloName data="all" /}<br>
  21. // Greet the additional people.
  22. {foreach $additionalName in $additionalNames}
  23. {call .helloName}
  24. {param name: $additionalName /}
  25. {/call}
  26. {if not isLast($additionalName)}
  27. <br> // break after every line except the last
  28. {/if}
  29. {ifempty}
  30. No additional people to greet.
  31. {/foreach}
  32. {/template}
  33. {/foreach}
  34. {if length($items) > 5}
  35. {msg desc="Says hello to the user."}
  36. {namespace ns autoescape="contextual"}
  37. /** Example. */
  38. {template .example}
  39. foo is {$ij.foo}
  40. {/template}