This allows variables defined in an outer context to be used in inner
contexts. For example:
<h2>{{foo}}</h2>
<ul>
{{#things}}
<!-- bar is a property of each thing, foo is an outer variable -->
<li>{{foo}} is a {{bar}}</li>
{{/things}}
</ul>
Bug: T203209
Change-Id: Ib0ae0fb0b4be6b161f548c79db6fb6f4b831f7c1
/**
* @var int Compilation flags passed to LightnCandy
*/
/**
* @var int Compilation flags passed to LightnCandy
*/
- // Do not add more flags here without discussion.
- // If you do add more flags, be sure to update unit tests as well.
- protected $compileFlags = LightnCandy::FLAG_ERROR_EXCEPTION;
+ protected $compileFlags;
/**
* @param string|null $templateDir
/**
* @param string|null $templateDir
public function __construct( $templateDir = null, $forceRecompile = false ) {
$this->templateDir = $templateDir ?: __DIR__ . '/templates';
$this->forceRecompile = $forceRecompile;
public function __construct( $templateDir = null, $forceRecompile = false ) {
$this->templateDir = $templateDir ?: __DIR__ . '/templates';
$this->forceRecompile = $forceRecompile;
+
+ // Do not add more flags here without discussion.
+ // If you do add more flags, be sure to update unit tests as well.
+ $this->compileFlags = LightnCandy::FLAG_ERROR_EXCEPTION | LightnCandy::FLAG_MUSTACHELOOKUP;
--- /dev/null
+{{foo}}
+{{#bar}}
+ {{foo}} {{baz}}
+{{/bar}}
+ [
+ 'parentvars',
+ [
+ 'foo' => 'f',
+ 'bar' => [
+ [ 'baz' => 'x' ],
+ [ 'baz' => 'y' ]
+ ]
+ ],
+ "f\n\n\tf x\n\n\tf y\n\n"
+ ]