Pagekit\View\Helper\ScriptHelper::render PHP Method

render() public method

Renders the script tags.
public render ( ) : string
return string
    public function render()
    {
        $output = '';
        foreach ($this->scripts as $script) {
            if ($source = $script->getSource()) {
                $attributes = '';
                foreach (['async', 'defer'] as $attribute) {
                    $attributes .= $script->getOption($attribute) ? ' ' . $attribute : '';
                }
                $output .= sprintf("        <script src=\"%s\"%s></script>\n", $source, $attributes);
            } elseif ($content = $script->getContent()) {
                $output .= sprintf("        <script>%s</script>\n", $content);
            }
        }
        return $output;
    }