Ejemplo n.º 1
0
    /**
     * Returns the HTML representation of the view element and its content.
     *
     * @return string
     */
    protected function render_outer_html()
    {
        $class = '';
        $type = \ICanBoogie\normalize($this->type);
        $m = $this->module;
        while ($m) {
            $normalized_id = \ICanBoogie\normalize($m->id);
            $class = "view--{$normalized_id}--{$type} {$class}";
            $m = $m->parent;
        }
        $this->element = new Element('div', ['id' => 'view-' . \ICanBoogie\normalize($this->id), 'class' => trim("view view--{$type} {$class}"), 'data-constructor' => $this->module->id]);
        $this->element = $this->alter_element($this->element);
        #
        $html = $o_html = $this->render_inner_html($this->engine->context);
        new RenderEvent($this, $html);
        #
        if (Debug::is_dev()) {
            $possible_templates = implode(PHP_EOL, $this->template_tries);
            $html = <<<EOT

<!-- Possible templates for view "{$this->id}":

{$possible_templates}

-->
{$html}
EOT;
        }
        $this->element[Element::INNER_HTML] = $html;
        $this->element['data-template-path'] = $this->template_pathname;
        return (string) $this->element;
    }