Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions HTML/Template/IT.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,12 @@ class HTML_Template_IT
var $_options = array(
'preserve_data' => false,
'use_preg' => true,
'preserve_input'=> true
'preserve_input'=> true,
'check_placeholder_exists' => true,
);

public static $globalOptions = [];

/**
* Builds some complex regular expressions and optionally sets the
* file root directory.
Expand All @@ -408,6 +411,9 @@ class HTML_Template_IT
*/
function __construct($root = '', $options = null)
{
if (!empty(self::$globalOptions)) {
$this->setOptions(self::$globalOptions);
}
if (!is_null($options)) {
$this->setOptions($options);
}
Expand Down Expand Up @@ -481,6 +487,16 @@ function setOptions($options)
return IT_OK;
}

/**
* Define global options used for all new instances.
* options defined using constructor parameter will overwrite
* globalOptions
*/
public static function setGlobalOptions($options)
{
self::$globalOptions = $options;
}

/**
* Print a certain block with all replacements done.
*
Expand Down Expand Up @@ -766,7 +782,7 @@ function setVariable($variable, $value = '')
$this->setVariable($key, $value);
}
} else {
if ($this->checkPlaceholderExists($this->currentBlock, $variable)) {
if (!$this->_options['check_placeholder_exists'] || $this->checkPlaceholderExists($this->currentBlock, $variable)) {
$this->variableCache[$variable] = $value;
}
}
Expand Down