First of all: Thanks
Originally posted by bubblenut
In both of the first two functions you have these two lines in the for each.
$position = isset($position) ? ++$position : 1;
$count = isset($count) ? $count : count($content);
[/b]
moved it above the foreach, $first is initialised to true before entering the loop as well
Also, the isset test on $first and $last is not necessary as you set them right before. You know they are going to be set.
No
everthing i return which is not in $data is a special var.
{_first} will be compiled into $first and the line
if (!isset($first)) $first = NULL;
is prepended in the function just before filling the $result var starts.
Thing is: within if-clauses i can't detect those vars properley (don't know where to write the initialisation stuff) and so my if converts every var to
(isset($name_of_var) ? $name_of_var : NULL)
In fact, if speed is of the essence then I would say do away with all your functions and make it completely procedural, after all, this is generated code, not intended to be read by anyone so readability need not be an issue.
I tested it and compared it with smarty which in fact does it procedural and i'm somewhat faster
And i'm able to do recursive calls with simply calling the function once again which is quite difficult if there are no functions
Another thing is that by using functions for all (including the main part of the template) i don't need to use output buffering for fetching the result
Have a look at http://www.howtodo.de/showcase/smarty_ext_compare/ and see what I mean
Any other optimization tips?
And for some explanation:
ExT2 means Extensible Template 2
You have commands, vars and modifiers.
Those 3 things are all stored in subfodlers of "extensions"-folder.
A command is used for my loop and my if for example (command.loop.php, command.if.php)
Vars contain compilation routines for special vars like {first} and {last} or {unique}
(var.unique.php would for example return
md5(mt_rand(1, 50).microtime())
so you can easyly stop pics from being cached by writing
img src="<some_dynamic_generated_pic_with_static_name.php"?{_unique}">
Modifiers modify the way how vars will be output.
{headline capitalize, escape} for example will capitalize all words in $date['headline'] and run htmlspecialchars on it afterwards
{now dateformat "d.m.Y"} will take the current time (now returns time()) and format it accoding to the string specified.