Currently, the templates are processed in the following order:
- Comments are removed from top to bottom
- Variables and their filters are evaluated from top to bottom
- Tags are evaluated from deepest nesting and top to bottom.
This works just fine if you have simple tags, doing simple things. I even got an if-then-else construction working, which I'm somewhat proud of (i.e. I'm proud that I got it working - the implementation is a matter on its own). But now I'm trying to get a foreach-construction working, and I'm knee deep in The Stuff.
Things shouldn't be all too hard to get working just well with consecutive foreach-constructs. Despite the fact that variables are evaluated into plaintext before tags are processes, I could get the callback variable working pretty easily from inside the foreach tag. But the problems start when foreach tags would be nested, which wouldn't be all too uncommon (think tables with unknown dimensions).
The problem lies in the deep-up process order of the tags. Normally, when doing nested foreach-constructs, we utilize the first (most shallow) foreach clause to get data into the child (deeper) foreach. But with this processing order, the ordering gets backwards and counter-intuitive. And I won't have anything counter-intuitive in this project.
So, I have two choices: Rewrite the template engine or skip more complicated (thus more useful) tags. Frankly, I would hate do either.
PS: Seems like the ordered list broke Google's stylesheet. It's always heartwarming to find bugs in other people's doings :)
No comments:
Post a Comment