diff --git a/HtmlBuilder.php b/HtmlBuilder.php index d98f3c9..38274e3 100644 --- a/HtmlBuilder.php +++ b/HtmlBuilder.php @@ -63,6 +63,38 @@ class HtmlBuilder { return html_entity_decode($value, ENT_QUOTES, 'UTF-8'); } + /** + * Generate a link to a JavaScript file. + * + * @param string $url + * @param array $attributes + * @return string + */ + public function script($url, $attributes = array()) + { + $attributes['src'] = $this->url->asset($url); + + return 'attributes($attributes).'>'.PHP_EOL; + } + + /** + * Generate a link to a CSS file. + * + * @param string $url + * @param array $attributes + * @return string + */ + public function style($url, $attributes = array()) + { + $defaults = array('media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'); + + $attributes = $attributes + $defaults; + + $attributes['href'] = $this->url->asset($url); + + return 'attributes($attributes).'>'.PHP_EOL; + } + /** * Generate an HTML image element. *