Support object instance attribute access; you must apply this if your data contains object.
This flag cause bad rendering performance, do not enable it unless you need this feature anyway.
The default behavior: only do associative array lookup
array(
"foo" => array(
"key" => "OK"
),
"date" => new DateTime()
)
,
OK,
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{foo.key}}, {{date.getTimestamp}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
"key" => "OK"
),
"date" => new DateTime()
);
echo $render($data);
executes method of an instance
Used option: FLAG_METHOD
array(
"foo" => array(
"key" => "OK"
),
"date" => new DateTime()
)
,
OK, 1647868442
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{foo.key}}, {{date.getTimestamp}}";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_METHOD
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
"key" => "OK"
),
"date" => new DateTime()
);
echo $render($data);