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:
Array
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:
1,3,5
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:
[object Object]
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);