/** * Remove a JavaScript SCRIPT element from the HTML HEAD section. * * @param string $source URL of JS file or file in assets folder * @param array $attributes Additional parameters for the script tag */ public static function removeScript($source, $attributes = array()) { $attributes['src'] = Assets::javascript_path($source); self::removeHeadElement('script', $attributes); }
function test_javascript_path_should_not_touch_absolute_paths() { $url = Assets::javascript_path('/some/script.js'); $this->assertEquals(STATIC_ASSETS_URL . 'some/script.js', $url); }
/** * Returns a script include tag per source given as argument. * * Examples: * * Assets::script('prototype') => * <script src="/javascript/prototype.js"></script> * * Assets::script('common.javascript', '/elsewhere/cools') => * <script src="/js/common.javascript"></script> * <script src="/elsewhere/cools.js"></script> */ static function script($atLeastOneArgument) { $html = ''; foreach (func_get_args() as $source) { $source = Assets::javascript_path($source); $html .= Assets::content_tag('script', '', array('src' => $source)); $html .= "\n"; } return $html; }