support {{foo.length}}
when foo is an array (simulate JavaScript Array.proto.length behavior)
The default behavior: foo.length
do not look for Array.length.
array(
"foo" => array(
1,
2,
3
),
"bar" => array(
"length" => "go",
"width" => 400
)
)
,
, go
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{foo.length}}, {{bar.length}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
1,
2,
3
),
"bar" => array(
"length" => "go",
"width" => 400
)
);
echo $render($data);
foo.length
will be Array.length.
Used option: FLAG_JSLENGTH
array(
"foo" => array(
1,
2,
3
),
"bar" => array(
"length" => "go",
"width" => 400
)
)
,
3, go
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{foo.length}}, {{bar.length}}";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_JSLENGTH
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
1,
2,
3
),
"bar" => array(
"length" => "go",
"width" => 400
)
);
echo $render($data);