public function script($assets, $name, $path = "", $cache = 0, $version = false)
{
$path = $this->path($path);
if (!$path) {
return null;
}
$src = rtrim($this->pathToUrl($path), '/') . "/{$name}.js" . ($version ? "?ver={$version}" : "");
$path .= "/{$name}.js";
$tag = '<script src="' . $src . '" type="text/javascript"></script>' . "\n";
if ($cache && file_exists($path) && time() - filemtime($path) < $cache) {
return $tag;
}
$result = $this->compile($assets, "js");
if ($result) {
file_put_contents($path, $result);
return $tag;
}
return null;
}