Create a new context for the partial. This option is same with handlbars.js explicitPartialContext option.
The default behavior is reusing current context when there is no argument for the partial.
Partials:| foo | BAR:{{bar}} |
|---|
array(
"bar" => "Good!"
)BAR:Good!require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{> foo}}";
$php = LightnCandy::compile($template, array(
"partials" => array(
"foo" => "BAR:{{bar}}"
)
));
$render = LightnCandy::prepare($php);
$data = array(
"bar" => "Good!"
);
echo $render($data);
Create an empty object as new context for the partial without argument. FLAG_RUNTIMEPARTIAL is required.
Used option: FLAG_PARTIALNEWCONTEXT FLAG_RUNTIMEPARTIAL
Partials:| foo | BAR:{{bar}} |
|---|
array(
"bar" => "Good!"
)BAR:require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{> foo}}";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_PARTIALNEWCONTEXT | LightnCandy::FLAG_RUNTIMEPARTIAL,
"partials" => array(
"foo" => "BAR:{{bar}}"
)
));
$render = LightnCandy::prepare($php);
$data = array(
"bar" => "Good!"
);
echo $render($data);