LightnCandy option: FLAG_JSLENGTH

support {{foo.length}} when foo is an array (simulate JavaScript Array.proto.length behavior)

Sample Codes

The default behavior: foo.length do not look for Array.length.

Data:
array(
  "foo" => array(
    1,
    2,
    3
  ),
  "bar" => array(
    "length" => "go",
    "width" => 400
  )
)
Template:
{{foo.length}}, {{bar.length}}
Result:
Command failed: php .exec_tmp_file 2>/dev/null
Source Code
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

Data:
array(
  "foo" => array(
    1,
    2,
    3
  ),
  "bar" => array(
    "length" => "go",
    "width" => 400
  )
)
Template:
{{foo.length}}, {{bar.length}}
Result:
Command failed: php .exec_tmp_file 2>/dev/null
Source Code
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);