From 520d1e6d83c5e3cd77b8881bc0a20eabac9a8d73 Mon Sep 17 00:00:00 2001 From: Maxime Fabre Date: Tue, 2 Apr 2013 22:40:18 +0300 Subject: [PATCH] Add missing HTML::script and HTML::style --- HtmlBuilder.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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. *