A List generated by a template - is it possible? HELP!

As I wrote above - the expected input is a list of lists e.g. [[1,2,3,4]] or [[1,2,3,4], [5,6,7,8]]. So my script at the end should generate a list of lists. If I switch on 4 input_booleans the script should end up with 4 lists inside a list. If I switch 2 - it should produce 2 lists within a list. Zero - a list with no elements etc.

Regarding the if-elif - my mistake. I made up these configs as the real ones I have in my scripts are a lot more complicated as they use offset calculation so for clarity purposes I simplified them.

Any other replies are welcome, however I think I will go with the idea proposed by @swiftlyfalling (thanks!) - a custom python script. It should be a lot simpler and the Python code will be definitely cleaner than these if-elif and {{}} crazy jinjia constructs.
I mentioned LUA - now I think that if I can produce a custom Python script - I dontt need LUA anymore. Python itself gives enough possibilities for scripting.