The next line is an included template. Look at templates/my-favorite-animal.st
My favorite animal is a: Tyrannasaurus Rex (set with setAttribute)
*********** My least favorite animal is Bambi.
*********** (set in another template, leastFavoriteAnimal.st)
*********** Notice that this template file uses CamelCase rather than dashes to separate words.
Otherwise there's an error with included templates.
So, in general: avoid template file names with dashes or underscores, and just use CamelCase for templates.
Numbers are also not allowed.
Try uncommenting the next line and see what you get:
If I forget to set an attribute (favoriteMammal), it just doesn't display:
This is what happens when an include fails: No Template Found for: nonexistingTemplate
The next bit includes a template from a template that is already an included template.
If I set the same attribute several times, it just shows up repeated. I think this is reasonable, because it gives you feedback that there's probably a bug in your program:
Favorite plant: SugarcaneFicusWheat
Favorite plant Two:
You can comment out parts of a template:
You can display lists: My favorite animal is a: (set with setAttribute)
*********** My least favorite animal is .
*********** (set in another template, leastFavoriteAnimal.st)
*********** Notice that this template file uses CamelCase rather than dashes to separate words.
Otherwise there's an error with included templates.
So, in general: avoid template file names with dashes or underscores, and just use CamelCase for templates.
Numbers are also not allowed.
Try uncommenting the next line and see what you get:
If I forget to set an attribute (favoriteMammal), it just doesn't display:
This is what happens when an include fails: No Template Found for: nonexistingTemplate
The next bit includes a template from a template that is already an included template.
If I set the same attribute several times, it just shows up repeated. I think this is reasonable, because it gives you feedback that there's probably a bug in your program:
Favorite plant:
Favorite plant Two:
You can comment out parts of a template:
You can display lists: zinc talc
The next line shows another strategy for including templates, generating them using let bindings in haskell, rather than using parenthesis to make StringTemplate do includes. Note that $ fp2 $ would be an illegal template var name, so we use fpTwo
If I set the same attribute several times, it just shows up repeated. I think this is reasonable, because it gives you feedback that there's probably a bug in your program:
Favorite plant:
Favorite plant Two: Venus Fly Trap