コード例 #1
0
 /**
  * Validate an end tag token.
  * @param MUNGER_TOKEN $token
  * @access private
  */
 protected function _transform_as_end_tag($token)
 {
     $name = $token->name();
     if (isset($this->_known_tags[$name])) {
         if ($this->_known_tags[$name]->has_end_tag) {
             $tag = array_pop($this->_open_tags);
             if (isset($tag)) {
                 if (!$tag->token->matches($token)) {
                     $this->add_error('Unexpected end tag ' . $tag->token->name() . '.', $token);
                     /* Put the tag back on the stack, so it can be matched if the correct
                      * tag shows up.
                      */
                     array_push($this->_open_tags, $tag);
                 }
             } else {
                 $this->add_error('Unexpected end tag [' . $name . '] (no tags are open).', $token);
             }
         } else {
             $this->add_error('Tag [' . $name . '] cannot have an end tag.', $token);
         }
     }
 }
コード例 #2
0
ファイル: munger.php プロジェクト: mvonballmo/earthli-webcore
 /**
  * Replace a tag with its actual content.
  * If the tag is known, then this uses the {@link MUNGER_REPLACER}s list. If it is unknown, it
  * calls {@link _known_tag_as_text()}, which transforms non-replaced known tags.
  * @param MUNGER_TOKEN $token
  * @return string
  * @access private
  */
 protected function _tag_as_text($token)
 {
     $name = $token->name();
     if (isset($this->_known_tags[$name])) {
         if (isset($this->_replacers[$name])) {
             $rep = $this->_replacers[$name];
             return $rep->transform($this, $token);
         }
         return $this->_known_tag_as_text($token);
     } else {
         if (!$this->strip_unknown_tags) {
             return $token->data();
         }
     }
     return '';
 }