LightnCandy option: FLAG_ADVARNAME

Support {{foo.[0].[#te#st].bar}} or {{"some string"}} or {{helper (subexpression ...)}} handlebars style extensions.

Sample Codes

Default to lookup [foo then bar]

Data:
array(
  "foo.bar" => "GOOD!",
  "foo" => array(
    "bar" => "BAD!"
  ),
  "[foo" => array(
    "bar]" => "Default!"
  )
)
Template:
{{[foo.bar]}}
Result:
Default!
Source Code
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

Data:
array(
  "foo.bar" => "GOOD!",
  "foo" => array(
    "bar" => "BAD!"
  )
)
Template:
{{[foo.bar]}}
Result:
GOOD!
Source Code
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);

See Also...