/** * Renders the HTML asset inclusion tags (script and link tags). * * TODO explosion of asset name can be done while generating cache. */ public function render($packages, $types = array(Dynamics::STYLESHEET, Dynamics::JAVASCRIPT)) { $html = PHP_EOL; foreach ($types as $type) { $extension = Dynamics::getExtensionFromType($type); if ($this->configuration->isSupercacheEnabled()) { // TODO FIXME $url = $this->routing->getCacheUrlFor($packages, $extension); if ($this->generateSupercache($url, $packages, $type)) { $html .= ' ' . $this->getTag($url, $type) . "\n"; } } else { foreach ($packages as $packageName => $package) { $assets = $package->{'get' . ucfirst($type) . 's'}(); if (count($assets)) { $html .= ' ' . $this->getTag($this->routing->getUrlFor($packageName, $extension), $type) . PHP_EOL; } } } } return $html; }
public function testGetUrlFor4() { $routing = new Dynamics_Routing(array(Dynamics_Routing::PATH_DEFAULT => '/asset/', 'js' => '/js/')); $this->assertEquals('/js/foo.js', $routing->getUrlFor('foo', 'js')); $this->assertEquals('/asset/bar.css', $routing->getUrlFor('bar', 'css')); }