LightnCandy option: FLAG_RUNTIMEPARTIAL

Compile the partial as callable. This enables recursive partials or context change for partials.

Sample Codes

Default is to compile the partial as static code

Used option: FLAG_JSOBJECT

Partials:
foo{{hello}}
Data:
NULL
Template:
OK{{> foo}}!
Result:
Command failed: php .exec_tmp_file 2>/dev/null
Source Code
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "OK{{> foo}}!";

$php = LightnCandy::compile($template, array(
  "flags" => LightnCandy::FLAG_JSOBJECT,
  "partials" => array(
    "foo" => "{{hello}}"
  )
));

echo $php

Compile used partial as embed callable code

Used option: FLAG_JSOBJECT FLAG_RUNTIMEPARTIAL

Partials:
foo{{hello}}
moo{{not used}}
Data:
NULL
Template:
OK{{> foo}}!
Result:
Command failed: php .exec_tmp_file 2>/dev/null
Source Code
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "OK{{> foo}}!";

$php = LightnCandy::compile($template, array(
  "flags" => LightnCandy::FLAG_JSOBJECT | LightnCandy::FLAG_RUNTIMEPARTIAL,
  "partials" => array(
    "foo" => "{{hello}}",
    "moo" => "{{not used}}"
  )
));

echo $php

Default to not support context change on partial

Used option: FLAG_ERROR_LOG

Partials:
foo{{hello}}
Data:
NULL
Template:
OK{{> foo bar}}!
Result:
Command failed: php .exec_tmp_file2>&1
Source Code
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "OK{{> foo bar}}!";

$php = LightnCandy::compile($template, array(
  "flags" => LightnCandy::FLAG_ERROR_LOG,
  "partials" => array(
    "foo" => "{{hello}}"
  )
));

Use another context for the partial

Used option: FLAG_RUNTIMEPARTIAL

Partials:
foo{{hello}}
Data:
array(
  "bar" => array(
    "hello" => "World"
  )
)
Template:
OK{{> foo bar}}!
Result:
Command failed: php .exec_tmp_file 2>/dev/null
Source Code
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "OK{{> foo bar}}!";

$php = LightnCandy::compile($template, array(
  "flags" => LightnCandy::FLAG_RUNTIMEPARTIAL,
  "partials" => array(
    "foo" => "{{hello}}"
  )
));
$render = LightnCandy::prepare($php);
$data = array(
  "bar" => array(
    "hello" => "World"
  )
);
echo $render($data);

When using dynamic partial, all partials will be compiled into your render function.

Used option: FLAG_RUNTIMEPARTIAL

Partials:
foo1Partial foo one
foo2Partial foo two
foo3Partial foo {{moo}}
Data:
NULL
Template:
{{> (foo)}}
Result:
Command failed: php .exec_tmp_file 2>/dev/null

Check the code to know used helper codes

Source Code
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{> (foo)}}";

$php = LightnCandy::compile($template, array(
  "flags" => LightnCandy::FLAG_RUNTIMEPARTIAL,
  "partials" => array(
    "foo1" => "Partial foo one",
    "foo2" => "Partial foo two",
    "foo3" => "Partial foo {{moo}}"
  ),
  "helpers" => array(
    "foo" => function () {
      return 'foo2';
    }
  )
));

echo $php

See Also...