mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
improvements
This commit is contained in:
parent
8767bfb9b0
commit
99ceb40c5f
|
|
@ -120,6 +120,7 @@ class Assets extends PropertyObject
|
|||
$this->assets_url = $locator->findResource('asset://', false);
|
||||
|
||||
// Initialize asset collection storage
|
||||
$this->assets[self::LINK_COLLECTION] = [];
|
||||
$this->assets[self::CSS_COLLECTION] = [];
|
||||
$this->assets[self::JS_COLLECTION] = [];
|
||||
$this->assets[self::JS_MODULE_COLLECTION] = [];
|
||||
|
|
@ -476,13 +477,31 @@ class Assets extends PropertyObject
|
|||
* @param array $attributes
|
||||
* @return string
|
||||
*/
|
||||
public function css($group = 'head', $attributes = [])
|
||||
public function css($group = 'head', $attributes = [], $include_link = true)
|
||||
{
|
||||
$output = $this->render(self::LINK, $group, $attributes);
|
||||
$output = '';
|
||||
|
||||
if ($include_link) {
|
||||
$output = $this->link($group, $attributes);
|
||||
}
|
||||
|
||||
$output .= $this->render(self::CSS, $group, $attributes);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the CSS link tags.
|
||||
*
|
||||
* @param string $group name of the group
|
||||
* @param array $attributes
|
||||
* @return string
|
||||
*/
|
||||
public function link($group = 'head', $attributes = [])
|
||||
{
|
||||
return $this->render(self::LINK, $group, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the JavaScript script tags.
|
||||
*
|
||||
|
|
@ -490,12 +509,36 @@ class Assets extends PropertyObject
|
|||
* @param array $attributes
|
||||
* @return string
|
||||
*/
|
||||
public function js($group = 'head', $attributes = [])
|
||||
public function js($group = 'head', $attributes = [], $include_js_module = true)
|
||||
{
|
||||
$output = $this->render(self::JS, $group, $attributes);
|
||||
$output .= $this->render(self::JS_MODULE, $group, $attributes);
|
||||
return $output;
|
||||
|
||||
if ($include_js_module) {
|
||||
$output .= $this->jsModule($group, $attributes);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Javascript Modules tags
|
||||
*
|
||||
* @param $group
|
||||
* @param $attributes
|
||||
* @return string
|
||||
*/
|
||||
public function jsModule($group = 'head', $attributes = [])
|
||||
{
|
||||
return $this->render(self::JS_MODULE, $group, $attributes);
|
||||
}
|
||||
|
||||
public function all($group = 'head', $attributes = [])
|
||||
{
|
||||
$output = $this->css($group, $attributes, false);
|
||||
$output .= $this->link($group, $attributes);
|
||||
$output .= $this->js($group, $attributes, false);
|
||||
$output .= $this->jsModule($group, $attributes);
|
||||
return $output;
|
||||
}
|
||||
|
||||
protected function isValidType($type)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user