So. I did see this question: How to use switch case in Mustache template?
Goal flow: php sets variables then calls up mustache template.
Currently its php jumbled with html and calls up mustache templates.
My question is about this sort of logic:
foreach ($things as $thing)
{
switch ($thing['trait']) {
case CONSTANT1:
// launch partial mustache template
case CONSTANT2:
// launch partial mustache template
case CONSTANT3:
// launch partial mustache template
}
}
I want to convert entirely to the mustache template where the php only feeds the mustache template variables. I got this far...
{{#things}}
{{#trait}}
// what do I do here?
{{/trait}}
{{/things}}
I am sorta confused about how access things while mustache does the looping.
If I do something like this and make constant1,2,3 variables...
{{#constant1}}
do stuff
{{/constant1}}
I am confused as to how those variables will be reset during looping if they are only set once in the php that calls this mustache template.