コード例 #1
0
ファイル: Printer.php プロジェクト: gunderjt/MtHaml
 public function enterText(Text $node)
 {
     $content = $node->getContent();
     $escaping = $node->getEscaping();
     if (true === $escaping->isEnabled()) {
         $flag = '&';
         if ($node->getEscaping()->isOnce()) {
             $flag .= '!';
         }
         $content = $flag . $content;
     } elseif (false === $escaping->isEnabled()) {
         $content = '!' . $content;
     }
     $this->raw('text(' . $content . ')');
 }
コード例 #2
0
 protected function parseTagAttributesHtml($buf)
 {
     $attrs = array();
     if ($buf->match('/\\(\\s*/A')) {
         do {
             if ($expr = $this->parseInterpolation($buf)) {
                 $attrs[] = new TagAttributeInterpolation($expr->getPosition(), $expr);
             } else {
                 if ($buf->match('/[\\w+:-]+/A', $match)) {
                     $name = new Text($match['pos'][0], $match[0]);
                     if (!$buf->match('/\\s*=\\s*/A')) {
                         $value = null;
                     } else {
                         $value = $this->parseAttrExpression($buf, ' ');
                     }
                     $attr = new TagAttribute($name->getPosition(), $name, $value);
                     $attrs[] = $attr;
                 } else {
                     $this->syntaxErrorExpected($buf, 'html attribute name or #{interpolation}');
                 }
             }
             if ($buf->match('/\\s*\\)/A')) {
                 break;
             }
             if (!$buf->match('/\\s+/A')) {
                 if (!$buf->isEol()) {
                     $this->syntaxErrorExpected($buf, "' ', ')' or end of line");
                 }
             }
             // allow line break
             if ($buf->isEol()) {
                 $buf->nextLine();
                 $buf->skipWs();
             }
         } while (true);
     }
     return $attrs;
 }
コード例 #3
0
 public function enterText(Text $node)
 {
     $string = $node->getContent();
     if ($this->isEchoMode()) {
         if ($node->getEscaping()->isEnabled()) {
             $once = $node->getEscaping()->isOnce();
             $string = $this->escapeHtml($string, !$once);
         }
         $string = $this->escapeLanguage($string);
         $this->raw($string);
     } else {
         $string = $this->stringLiteral($string);
         $this->raw($string);
     }
 }
コード例 #4
0
ファイル: Parser.php プロジェクト: gunderjt/MtHaml
 private function parseTagAttributeHtml(Buffer $buf)
 {
     if ($expr = $this->parseInterpolation($buf)) {
         return new TagAttributeInterpolation($expr->getPosition(), $expr);
     }
     if ($buf->match('/[\\w+:-]+/A', $match)) {
         $name = new Text($match['pos'][0], $match[0]);
         if (!$buf->match('/\\s*=\\s*/A')) {
             $value = null;
         } else {
             $value = $this->parseAttrExpression($buf, ' ');
         }
         return new TagAttribute($name->getPosition(), $name, $value);
     }
     throw $this->syntaxErrorExpected($buf, 'html attribute name or #{interpolation}');
 }