public function renderSection($template, $section, array $data = [], $class = null)
    {
        if (! is_array($section) && ! is_string($section)) {
            throw new InvalidArgumentException(
                'Section to render must be passed as string or array of strings.'
            );
        }
        $sections = is_string($section) ? [$section] : array_filter($section, 'is_string');
        $outputs = new \stdClass();
        $setter = function ($name, $content) use ($sections, $outputs) {
            in_array($name, $sections, true) and $outputs->$name = $content;
        };
        $this->events->on('f.sections.content', $setter);
        $this->render($template, $data, $class);
        $this->events->removeListener('f.sections.content', $setter);
        $result = array_merge(array_fill_keys($sections, ''), get_object_vars($outputs));

        return is_array($section) ? $result : $result[$section];
    }
public function renderSection($template, $section, array $data = [], $class = null)
    {
        if (! is_array($section) && ! is_string($section)) {
            throw new InvalidArgumentException(
                'Section to render must be passed as string or array of strings.'
            );
        }
        $sections = is_string($section) ? [$section] : array_filter($section, 'is_string');
        $outputs = new \stdClass();
        $setter = function ($name, $content) use ($sections, $outputs) {
            in_array($name, $sections, true) and $outputs->$name = $content;
        };
        $this->events->on('f.sections.content', $setter);
        $this->render($template, $data, $class);
        $this->events->removeListener('f.sections.content', $setter);
        $result = array_merge(array_fill_keys($sections, ''), get_object_vars($outputs));

        return is_array($section) ? $result : $result[$section];
    }
public function renderSection ( $ template , $ section , array $ data = [ ] , $ class = null ) { if ( ! is_array ( $ section ) && ! is_string ( $ section ) ) { throw new InvalidArgumentException ( 'Section to render must be passed as string or array of strings.' ) ; } $ sections = is_string ( $ section ) ? [ $ section ] : array_filter ( $ section , 'is_string' ) ; $ outputs = new \ stdClass ( ) ; $ setter = function ( $ name , $ content ) use ( $ sections , $ outputs ) { in_array ( $ name , $ sections , true ) and $ outputs -> $ name = $ content ; } ; $ this -> events -> on ( 'f.sections.content' , $ setter ) ; $ this -> render ( $ template , $ data , $ class ) ; $ this -> events -> removeListener ( 'f.sections.content' , $ setter ) ; $ result = array_merge ( array_fill_keys ( $ sections , '' ) , get_object_vars ( $ outputs ) ) ; return is_array ( $ section ) ? $ result : $ result [ $ section ] ; }
Renders a template and returns the rendered content of a specific passed section.
Section param can also be an array of section names in which case the method will return
an array where keys are required section names, values the related rendered content.

@param  string       $template
@param  string|array $section
@param  array        $data
@param  string|null  $class
@return string
Renders a template and returns the rendered content of a specific passed section . Section param can also be an array of section names in which case the method will return an array where keys are required section names values the related rendered content .