Texy\HtmlElement::create PHP Method

create() final public method

Creates and adds a new HtmlElement child.
final public create ( $name, $attrs = NULL ) : HtmlElement
return HtmlElement created element
    public final function create($name, $attrs = NULL)
    {
        $this->insert(NULL, $child = new self($name, $attrs));
        return $child;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Finish invocation.
  * @return Texy\HtmlElement
  */
 public function solve(Texy\HandlerInvocation $invocation, $phrase, $content, Modifier $mod, Texy\Link $link = NULL)
 {
     $texy = $this->texy;
     $tag = isset($this->tags[$phrase]) ? $this->tags[$phrase] : NULL;
     if ($tag === 'a') {
         $tag = $link && $this->linksAllowed ? NULL : 'span';
     }
     if ($phrase === 'phrase/code') {
         $content = $texy->protect(htmlspecialchars($content, ENT_NOQUOTES, 'UTF-8'), $texy::CONTENT_TEXTUAL);
     }
     if ($phrase === 'phrase/strong+em') {
         $el = new Texy\HtmlElement($this->tags['phrase/strong']);
         $el->create($this->tags['phrase/em'], $content);
         $mod->decorate($texy, $el);
     } elseif ($tag) {
         $el = new Texy\HtmlElement($tag, $content);
         $mod->decorate($texy, $el);
         if ($tag === 'q') {
             $el->attrs['cite'] = $mod->cite;
         }
     } else {
         $el = $content;
         // trick
     }
     if ($link && $this->linksAllowed) {
         return $texy->linkModule->solve(NULL, $link, $el);
     }
     return $el;
 }