Thursday, December 28, 2006

tagName in containers

Due to problems with Internet Explorer, containers now have an attribute "tagname", that is used when it's time to render it.

For example, when you have an elements list (ul), and this kind of template:

<ul id="list">
<container class="ListElement">
</ul>

after adding 2 List Elements, the rendered HTMl will look like

<ul id="list">
<li id="list:1">1st Element</li>
<li id="list:2">2nd Element</li>
<div style="visibliity:hidden"/>
</ul>

The div element will not render correctly in IE, causing AJAX to stop working. Here's where you need to use the "tagname" attribute:

<ul id="list">
<container class="ListElement" tagname="li">
</ul>

creating this HTML

<ul id="list">
<li id="list:1">1st Element</li>
<li id="list:2">2nd Element</li>
<li style="visibliity:hidden"/>
</ul>

Which renders correctly.

Templates just use the tagname of their first element.

Labels:

Sunday, December 17, 2006

One-File Compiling

Now you can use the compiling option "recursive" (compile=,recursive), to compile an all in one file.

It's not yet usable for modules without a module inclusion file (/.php), and creates one file for each module (including all the aplication in just one file needs some working on, still).

Labels: ,

Wednesday, December 06, 2006

Programming By Contract and TypeChecking

Using our recently developed macros, we added programming by contract and typechecking support.

Setting compile=assertions,typechecking in your config.php, you can enable or disable it.

How to use it:

function drawRectangle($canvas, $x0, $y0, $x1, $y1) {
#typecheck $canvas: Canvas#
#check $x0 > $x1#
#check $y0 > $y1#
$canvas->draw(new Rectangle($x0, $y0, $x1, $y1));
}

Disabling the checks, improves performance, but checks are great for developing.
We are already adding checks in the main code.

Labels:

Tuesday, December 05, 2006

Macros!

We now have macros.

Files with macros, are included with compile_once() (which handles preprocessing, as well as smart recompiling).

Then, macros are used like this:

#check is_array($x)#

that is, they are surrounded by "#", and have the name of the macro, and the parameters.

To define a macro, just define the macro handler function:

function check($code){
if (defined('assertions')) {
return "assert($code);"
} else {
return '';
}
}

Macro function return compilable code (a string) based on the input string.

Labels: