Example #1
0
 /**
  * Assigns a template variable with a value
  * @param string|array $key template file reference
  * @param mixed $val (primitive types or \Jazz\Output
  * @throws \InvalidArgumentException
  */
 public function assign($key, $val = null)
 {
     if (is_array($key)) {
         parent::assign($key);
     } else {
         // verify precondition
         if ($val !== null && !is_bool($val) && !is_string($val) && !is_numeric($val) && !$val instanceof \Jazz\IOutput) {
             throw new \InvalidArgumentException('val');
         }
         parent::assign($key, $val);
     }
 }
Example #2
0
 /**
  * Imports template variables from another Template
  *
  * Default behavior is to overwrite any common template variable
  * keys with the values being imported.  The Ignore option will
  * bypass common keys, keeping the current value as is.
  *
  * @param \Jazz\ATemplate $engine
  * @param bool $ignore
  */
 public function import(\Jazz\ATemplate $engine, $ignore = false)
 {
     if (!is_bool($ignore)) {
         $ignore = false;
     }
     foreach ($engine->all() as $key => $val) {
         if ($ignore && !$this->has($key) || !$ignore) {
             $this->assign($key, $val);
         }
     }
 }