Support {{foo.[0].[#te#st].bar}} or {{"some string"}} or {{helper (subexpression ...)}} handlebars style extensions.
Default to lookup [foo then bar]
array(
"foo.bar" => "GOOD!",
"foo" => array(
"bar" => "BAD!"
),
"[foo" => array(
"bar]" => "Default!"
)
)Default!require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{[foo.bar]}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo.bar" => "GOOD!",
"foo" => array(
"bar" => "BAD!"
),
"[foo" => array(
"bar]" => "Default!"
)
);
echo $render($data);
Protect variable names by [ and ] when they contains special characters.
Used option: FLAG_ADVARNAME
array(
"foo.bar" => "GOOD!",
"foo" => array(
"bar" => "BAD!"
)
)GOOD!require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{[foo.bar]}}";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_ADVARNAME
));
$render = LightnCandy::prepare($php);
$data = array(
"foo.bar" => "GOOD!",
"foo" => array(
"bar" => "BAD!"
)
);
echo $render($data);