|
|
|
|
|
by flir
845 days ago
|
|
> as PHP files don't take parameters $_SERVER, $_POST, $_GET. The rest is not the PHP3 I recognize to be honest, let alone the modern stuff. Remember include() literally just included the code right there, inline, so you could include in functions and gain the function's scope: function render($data) {
switch ($data['foo']) {
case 'bar': include('bar.inc'); break;
case 'baz': include('baz.inc'); break;
}
}
That's your template router with all the template's data pre-loaded in the template's scope, be it ever so filthy. |
|
> Remember include() literally just included the code right there, inline, so you could include in functions and gain the function's scope:
I've talked about this approach elsewhere in thread, it is not nestable without building a way to "call" templates on top of require/include, and when you do that you'll need to undefined the render function to do it as well, which creates additional complexity. At that point, the original premise of just using raw PHP isn't very true, because you are now building a framework or templating system around it.
Also, you have to contend with the magic "render" function not being globally defined by something. It's messy.