Пример #1
0
 /**
  * Formats modifiers calling.
  * @param  MacroTokens
  * @param  string
  * @throws CompileException
  * @return MacroTokens
  */
 public function modifiersFilter(MacroTokens $tokens, $var)
 {
     $inside = FALSE;
     $res = new MacroTokens($var);
     while ($tokens->nextToken()) {
         if ($tokens->isCurrent(MacroTokens::T_WHITESPACE)) {
             $res->append(' ');
         } elseif ($inside) {
             if ($tokens->isCurrent(':', ',')) {
                 $res->append(', ');
                 $tokens->nextAll(MacroTokens::T_WHITESPACE);
             } elseif ($tokens->isCurrent('|')) {
                 $res->append(')');
                 $inside = FALSE;
             } else {
                 $res->append($tokens->currentToken());
             }
         } else {
             if ($tokens->isCurrent(MacroTokens::T_SYMBOL)) {
                 if ($this->compiler && $tokens->isCurrent('escape')) {
                     $res = $this->escapeFilter($res);
                     $tokens->nextToken('|');
                 } else {
                     $res->prepend('$template->' . $tokens->currentValue() . '(');
                     $inside = TRUE;
                 }
             } else {
                 throw new CompileException("Modifier name must be alphanumeric string, '" . $tokens->currentValue() . "' given.");
             }
         }
     }
     if ($inside) {
         $res->append(')');
     }
     return $res;
 }