コード例 #1
0
 /**
  * Handles HAML multiline syntax
  *
  * Any line terminated by ` |` is concatenated with the following lines
  * also terminated by ` |`. Empty or whitespace-only lines are ignored. The
  * current line is replaced by the resulting line in $buf.
  *
  * @param Buffer $buf
  */
 public function handleMultiline($buf)
 {
     $line = $buf->getLine();
     if (!$this->isMultiline($line)) {
         return;
     }
     $line = substr(rtrim($line), 0, -1);
     while ($next = $buf->peekLine()) {
         if (trim($next) == '') {
             $buf->nextLine();
             continue;
         }
         if (!$this->isMultiline($next)) {
             break;
         }
         $line .= substr(trim($next), 0, -1);
         $buf->nextLine();
     }
     $buf->replaceLine($line);
 }
コード例 #2
0
ファイル: Parser.php プロジェクト: gunderjt/MtHaml
 protected function parseFilter(Buffer $buf)
 {
     if (!$buf->match('/:(.*)/A', $match)) {
         return null;
     }
     $node = new Filter($match['pos'][0], $match[1]);
     while (null !== ($next = $buf->peekLine())) {
         $indent = '';
         if ('' !== trim($next)) {
             $indent = $this->indent->getString(1, $next);
             if ('' === $indent) {
                 break;
             }
             if (strpos($next, $indent) !== 0) {
                 break;
             }
         }
         $buf->nextLine();
         $buf->eatChars(strlen($indent));
         $str = $this->parseInterpolatedString($buf, false);
         $node->addChild(new Statement($str->getPosition(), $str));
     }
     return $node;
 }