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"
),
"bar" => (object)Array('key' => 'Good')
)
,
OK,
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{foo.key}}, {{bar.key}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
"key" => "OK"
),
"bar" => (object)Array('key' => 'Good')
);
echo $render($data);
do instance property lookup
Used option: FLAG_PROPERTY
array(
"foo" => array(
"key" => "OK"
),
"bar" => (object)Array('key' => 'Good')
)
,
OK, Good
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{foo.key}}, {{bar.key}}";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_PROPERTY
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
"key" => "OK"
),
"bar" => (object)Array('key' => 'Good')
);
echo $render($data);