@@ -389,9 +389,12 @@ class HTML_Template_IT
389389 var $ _options = array (
390390 'preserve_data ' => false ,
391391 'use_preg ' => true ,
392- 'preserve_input ' => true
392+ 'preserve_input ' => true ,
393+ 'check_placeholder_exists ' => true ,
393394 );
394395
396+ public static $ globalOptions = [];
397+
395398 /**
396399 * Builds some complex regular expressions and optionally sets the
397400 * file root directory.
@@ -408,6 +411,9 @@ class HTML_Template_IT
408411 */
409412 function __construct ($ root = '' , $ options = null )
410413 {
414+ if (!empty (self ::$ globalOptions )) {
415+ $ this ->setOptions (self ::$ globalOptions );
416+ }
411417 if (!is_null ($ options )) {
412418 $ this ->setOptions ($ options );
413419 }
@@ -481,6 +487,16 @@ function setOptions($options)
481487 return IT_OK ;
482488 }
483489
490+ /**
491+ * Define global options used for all new instances.
492+ * options defined using constructor parameter will overwrite
493+ * globalOptions
494+ */
495+ public static function setGlobalOptions ($ options )
496+ {
497+ self ::$ globalOptions = $ options ;
498+ }
499+
484500 /**
485501 * Print a certain block with all replacements done.
486502 *
@@ -766,7 +782,7 @@ function setVariable($variable, $value = '')
766782 $ this ->setVariable ($ key , $ value );
767783 }
768784 } else {
769- if ($ this ->checkPlaceholderExists ($ this ->currentBlock , $ variable )) {
785+ if (! $ this -> _options [ ' check_placeholder_exists ' ] || $ this ->checkPlaceholderExists ($ this ->currentBlock , $ variable )) {
770786 $ this ->variableCache [$ variable ] = $ value ;
771787 }
772788 }
0 commit comments