Extends
lithium\template\Helper
Returns a JavaScript include tag (`<script />` element). If the filename is prefixed with
`"/"`, the path will be relative to the base path of your application. Otherwise, the path
will be relative to your JavaScript path, usually `webroot/js`.
Parameters
- mixed $path String path to JavaScript file, or an array of paths.
- array $options
Returns
stringSource
public function script($path, array $options = array()) {
$defaults = array('inline' => true);
list($scope, $options) = $this->_options($defaults, $options);
if (is_array($path)) {
foreach ($path as $i => $item) {
$path[$i] = $this->script($item, $scope);
}
return ($scope['inline']) ? join("\n\t", $path) . "\n" : null;
}
$m = __METHOD__;
$params = compact('path', 'options');
$script = $this->_filter(__METHOD__, $params, function($self, $params, $chain) use ($m) {
return $self->invokeMethod('_render', array($m, 'script', $params));
});
if ($scope['inline']) {
return $script;
}
if ($this->_context) {
$this->_context->scripts($script);
}
}