| ||||||||||
| ||||||||||
| Description | ||||||||||
A simple templating system with variable substitution and conditionals. Example: renderTemplate [("name","Sam"),("salary","50,000")] $
"Hi, $name$. $if(salary)$You make $$$salary$.$else$No salary data.$endif$"
"Hi, John. You make $50,000."
A slot for an interpolated variable is a variable name surrounded by dollar signs. To include a literal $ in your template, use $$. Variable names must begin with a letter and can contain letters, numbers, _, and -. The value of a variable will be indented to the same level as the variable. A conditional begins with $if(variable_name)$ and ends with $endif$. It may optionally contain an $else$ section. The if section is used if variable_name has a non-null value, otherwise the else section is used. Conditional keywords should not be indented, or unexpected spacing problems may occur. If a variable name is associated with multiple values in the association list passed to renderTemplate, you may use the $for$ keyword to iterate over them: renderTemplate [("name","Sam"),("name","Joe")] $
"$for(name)$\nHi, $name$.\n$endfor$"
"Hi, Sam.\nHi, Joe."
You may optionally specify separators using $sep$: renderTemplate [("name","Sam"),("name","Joe"),("name","Lynn")] $
"Hi, $for(name)$$name$$sep$, $endfor$"
"Hi, Sam, Joe, Lynn."
| ||||||||||
| Synopsis | ||||||||||
| ||||||||||
| Documentation | ||||||||||
| renderTemplate | ||||||||||
| ||||||||||
| class TemplateTarget a | ||||||||||
| ||||||||||
| getDefaultTemplate | ||||||||||
| ||||||||||
| Produced by Haddock version 2.6.0 | ||||||||||