AssetCompress\View\Helper\AssetCompressHelper::script PHP Method

script() public method

To create build files without configuration use addScript() Options: - All options supported by HtmlHelper::css() are supported. - raw - Set to true to get one script element for each file in the build.
public script ( string $file, array $options = [] ) : A
$file string A build target to include.
$options array An array of options for the script tag.
return A script tag
    public function script($file, $options = [])
    {
        $file = $this->_addExt($file, '.js');
        if (!$this->collection()->contains($file)) {
            throw new RuntimeException("Cannot create a script tag for a '{$file}'. That build is not defined.");
        }
        $output = '';
        if (!empty($options['raw'])) {
            unset($options['raw']);
            $target = $this->collection()->get($file);
            foreach ($target->files() as $part) {
                $path = $this->_relativizePath($part->path());
                if (DS === '\\') {
                    $path = str_replace(DS, '/', $path);
                }
                $output .= $this->Html->script($path, $options);
            }
            return $output;
        }
        $url = $this->url($file, $options);
        unset($options['full']);
        return $this->Html->script($url, $options);
    }