Agreed.
I don't think the template language should be expanded much further in a core phpBB install, but I think it is important for each tag implemented to be modular, allowing anyone to easily add logic they require or remove logic they don't.
[RFC] Template procedures
Re: Template procedures
+1 to this ie it would be far less confusing and would require less delving into file upon file to figure wtf is happening, and would lead to better themes IE shortform like WPnaderman wrote:Slowly I'm starting to wonder why we don't just use PHP instead of our own template language?
Re: [RFC] Template procedures
So - bumping this back after Nil's noted it's existence. I see this is as a kind of "macro" solution (rather than snippet, procedure, function - though a function is what it is). If you were able to send it parameters I could see a use, perhaps. There would also need to be mechanism (imo) to autoload such a macro's template since it could be used anywhere/everywhere and including it manually somewhat defeats the point and could lead to issues (unless it's loaded within the headers).
Re: [RFC] Template procedures
What does this offer that file inclusion does not?
Re: [RFC] Template procedures
That's a good question and one I've asked myself. I guess in certain circumstances it could lead to fewer includes - the pagination change I made for example. It may offer up more options than a simple include can achieve (unless it's been extended in my absence ofc ) such as per my example. It seems at the time it had a reasonable fan base - hopefully those peeps can provide more examples (or correct mine!).
Re: [RFC] Template procedures
I'd say the main prolem is with loops. The way that template variables work an included template file will be using a variable at the top level (or at least some specific level) so you won't be able to reuse the template file inside of a loop as the values will be in loop variables, which don't apply to the included template. So you need some way of specifying which template variables should be top level variables for the included template, essentially ending up with a function/macro mechanism.
Re: [RFC] Template procedures
OK, but please consider if passing local variables to included files (either explicitly or implicitly) might be a better approach.
Re: [RFC] Template procedures
Indeed, when I pointed psoTFX here, I didn't mean to favour any particular implementation.
However I think it would add to clarity if one explicitly defines which variables are parameters and need to be passed into the macro, rather than implicitly expecting variable to be set by whoever includes a template.
However I think it would add to clarity if one explicitly defines which variables are parameters and need to be passed into the macro, rather than implicitly expecting variable to be set by whoever includes a template.