Ejemplo n.º 1
0
 /**
  * Run a function and autoescape returned content if autoescape is turned on
  *
  * @param  string $function Callback name
  * @return mixed
  */
 private function doRun($function)
 {
     $raw = $this->execute($function, $this->functions, array_slice(func_get_args(), 1));
     if ($this->autoescape && !in_array($function, $this->safe, true) && (is_array($raw) || is_string($raw) || is_object($raw) && !$raw instanceof Extension)) {
         $raw = $this->escaper->escape($raw);
         if (is_object($raw)) {
             $raw = '';
         }
     }
     return is_null($raw) ? '' : $raw;
 }
Ejemplo n.º 2
0
 /**
  * Allow dot syntax access to any data
  *
  * @param  mixed        $data
  * @param  string|array $where
  * @param  bool         $strict
  * @return mixed
  */
 public function getIn($data, $where, $strict = false)
 {
     if (is_object($data)) {
         $clone = clone $data;
         $data = \Foil\arraize($clone, $this->autoescape);
     } elseif (!is_array($data)) {
         return $this->autoescape ? $this->escaper->escape($data) : $data;
     }
     $where = is_string($where) ? explode('.', $where) : (array) $where;
     $get = igorw\get_in($data, $where);
     if (!$strict || !$this->strict || !is_null($get)) {
         return $get;
     }
     $name = implode('.', $where);
     if ($this->strict === 'notice') {
         return trigger_error("{$name} is not defined.");
     }
     throw new RuntimeException("{$name} is not defined.");
 }
Ejemplo n.º 3
0
 /**
  * @param  array $funcArgs
  * @param  int   $slice
  * @return array
  */
 private function args(array $funcArgs, $slice = 2)
 {
     $args = array_filter(array_slice($funcArgs, $slice), 'is_scalar');
     return $this->options['autoescape'] ? $this->escaper->escape($args) : $args;
 }