LightnCandy option: FLAG_JSOBJECT

Align object or associative array conversion logic with JavaScript.

Sample Codes

The default behavior: may cause 'Array to string conversion' warning in PHP > 5.4

Data:
array(
  "foo" => array(
    "bar" => "OK"
  )
)
Template:
{{foo}}
Result:
Command failed: php .exec_tmp_file 2>/dev/null
Source Code
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{foo}}";

$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
  "foo" => array(
    "bar" => "OK"
  )
);
echo $render($data);

Same behavior with handlebars.js and mustache.js.

Used option: FLAG_JSOBJECT

Data:
array(
  "foo" => array(
    1,
    3,
    5
  )
)
Template:
{{foo}}
Result:
Command failed: php .exec_tmp_file 2>/dev/null
Source Code
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{foo}}";

$php = LightnCandy::compile($template, array(
  "flags" => LightnCandy::FLAG_JSOBJECT
));
$render = LightnCandy::prepare($php);
$data = array(
  "foo" => array(
    1,
    3,
    5
  )
);
echo $render($data);

Used option: FLAG_JSOBJECT

Data:
array(
  "foo" => array(
    "bar" => "OK"
  )
)
Template:
{{foo}}
Result:
Command failed: php .exec_tmp_file 2>/dev/null
Source Code
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{foo}}";

$php = LightnCandy::compile($template, array(
  "flags" => LightnCandy::FLAG_JSOBJECT
));
$render = LightnCandy::prepare($php);
$data = array(
  "foo" => array(
    "bar" => "OK"
  )
);
echo $render($data);