Resolve {{this}}
as {{.}}
. Otherwise, {{this}}
will lookup the variable 'this'.
The default behavior: {{this}}
will look for the value of 'this' key.
Used option: FLAG_JSOBJECT
array(
"this" => "is good"
)
==
is good == [object Object]
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{this}} == {{.}}";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_JSOBJECT
));
$render = LightnCandy::prepare($php);
$data = array(
"this" => "is good"
);
echo $render($data);
{{this}}
means {{.}}
Used option: FLAG_JSOBJECT FLAG_THIS
array(
"this" => "is good"
)
==
[object Object] == [object Object]
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{this}} == {{.}}";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_JSOBJECT | LightnCandy::FLAG_THIS
));
$render = LightnCandy::prepare($php);
$data = array(
"this" => "is good"
);
echo $render($data);