I'm using Leaf Tau, but I think that in 'standard' Leaf the problem is similar (just some other keywords).
So far my pages are created in a way I call "bottom up". I render the most specific part and then work my way up using #inline
eg. in my list.leaf I have :
#define(body):
//my html
#enddefine
#inline("main/subMenus")
then I have my subMenus file
#define(subMenus):
//some html
#evaluate(body)
#enddefine
#inline("main/mainMenu")
then I have may mainMenu file
#define(mainMenu):
//some html
#evaluate(subMenus)
#enddefine
#inline("main/index")
and on top of that my index file. In my controller I would then render the list.leaf file with the #define(body) in it.
So far this has worked perfectly for about 40 different pages (list and recordpages) in this project, but now the need arises for something completely different on the level of the body. I need several different bodies in one page.
Let me clear this out a bit: the user has the option in te application to create different type of actions. Some actions have 2 fields and an image, others have 12 fields, others 5 fields 3 images,... so they will be completely different rendered. Each action has a name: eg.: Promotion, Invitation, ...
The user can have many different actions so to my leaf template I will pass an array of actions and I then would like to render those actions. So in pseudocode my body file would look like :
#define(body)
#for(action in actions):
#evaluate(action.name)
#endfor
#enddefine
#inline("main/subMenus")
There are several problems however:
- I could define each action in that body file on top, but rather have them in separate files. So adding an action to the program would mean, on the level of leaf templates, adding 1 file with the definition and html. I don't know how this can be done however
- #evaluate(action.name) is not working it seems I can't use a variable but need to use a hardcoded static name
Can someone help me on how to formulate correctly or a better approach on this problem