zordius/lightncandy — pull request #4 by puritys (2014-01-27 06:28:41+00:00)
Title: Fix php warning, when render a index zero of array

When I run the php code at the bottom of comment. It will echo a warning that is 「PHP Warning: Invalid argument supplied for foreach() in /lightncandy.inc on line 549」.

The warning was happened in LightnCandy::compile() function.
I had try @LightnCandy::compile() to hide this warning.
But I thought it is wrong to hide warning message at compilation.

The root cause is this code "{{0}}", "{{}}" will be replaced to be a "null". It will cause "for-each" to output a warning.
I thought "{{}}" should not be exist in lightncandy template.
So I changed the return value of "{{0}}" to be "array(0)".

Or any better idea?

============= test code =================
LightnCandy::FLAG_HANDLEBARSJS));

$renderer = LightnCandy::prepare($php);

$data = array();
$data[] = array("John", "12");
$data[] = array("Marry", "22");

echo $renderer(Array('list' => $data));