From a778e5cca515499430f65f14735ac2e3538934ad Mon Sep 17 00:00:00 2001 From: dimas galih Date: Wed, 15 Jan 2020 19:33:22 +0700 Subject: [PATCH] Group of Html::script and Html::style Html for adding scripts and styles can be done with an array --- src/HtmlBuilder.php | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/HtmlBuilder.php b/src/HtmlBuilder.php index c9ed8d38..d4fe8c3b 100755 --- a/src/HtmlBuilder.php +++ b/src/HtmlBuilder.php @@ -81,6 +81,30 @@ public function script($url, $attributes = [], $secure = null) return $this->toHtmlString('attributes($attributes) . '>'); } + /** + * Generate a single or group of link to a JavaScript file. + * + * @param string $url + * @param array $attributes + * @param bool $secure + * + * @return \Illuminate\Support\HtmlString + */ + public function scripts($url, $attributes = [], $secure = null) + { + if (is_array($url)) { + $arr = []; + + foreach ($url as $key => $value) { + $arr[] = $this->script($value, $attributes, $secure); + } + + return implode("\r\n", $arr); + } else { + return $this->script($url, $attributes, $secure); + } + } + /** * Generate a link to a CSS file. * @@ -101,6 +125,30 @@ public function style($url, $attributes = [], $secure = null) return $this->toHtmlString('attributes($attributes) . '>'); } + /** + * Generate a single or group of link to a CSS file. + * + * @param string $url + * @param array $attributes + * @param bool $secure + * + * @return \Illuminate\Support\HtmlString + */ + public function styles($url, $attributes = [], $secure = null) + { + if (is_array($url)) { + $arr = []; + + foreach ($url as $key => $value) { + $arr[] = $this->style($value, $attributes, $secure); + } + + return implode("\r\n", $arr); + } else { + return $this->style($url, $attributes, $secure); + } + } + /** * Generate an HTML image element. *