Skip to content

Commit

Permalink
[AsseticBundle] fixed bundle notation of inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
kriswallsmith authored and fabpot committed Feb 19, 2011
1 parent c01be42 commit 4ba0e0d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/Symfony/Bundle/AsseticBundle/Factory/AssetFactory.php
Expand Up @@ -30,13 +30,13 @@ public function __construct(Kernel $kernel, $baseDir, $debug = false)
parent::__construct($baseDir, $debug);
}

protected function parseAsset($sourceUrl)
protected function parseInput($input)
{
// expand bundle notation
if ('@' == $sourceUrl[0] && false !== strpos($sourceUrl, '/')) {
$sourceUrl = $this->kernel->locateResource($sourceUrl);
if ('@' == $input[0] && false !== strpos($input, '/')) {
$input = $this->kernel->locateResource($input);
}

return parent::parseAsset($sourceUrl);
return parent::parseInput($input);
}
}
6 changes: 3 additions & 3 deletions src/Symfony/Bundle/AsseticBundle/Tests/FunctionalTest.php
Expand Up @@ -85,7 +85,7 @@ public function testTwigRenderDebug()
$content = $container->get('templating')->render('::layout.html.twig');
$crawler = new Crawler($content);

$this->assertEquals(2, count($crawler->filter('link[href$=".css"]')));
$this->assertEquals(3, count($crawler->filter('link[href$=".css"]')));
$this->assertEquals(2, count($crawler->filter('script[src$=".js"]')));
}

Expand All @@ -103,14 +103,14 @@ public function testPhpRenderDebug()
$content = $container->get('templating')->render('::layout.html.php');
$crawler = new Crawler($content);

$this->assertEquals(2, count($crawler->filter('link[href$=".css"]')));
$this->assertEquals(3, count($crawler->filter('link[href$=".css"]')));
$this->assertEquals(2, count($crawler->filter('script[src$=".js"]')));
}

public function provideDebugAndAssetCount()
{
return array(
array(true, 4),
array(true, 5),
array(false, 2),
);
}
Expand Down
22 changes: 22 additions & 0 deletions src/Symfony/Bundle/AsseticBundle/Tests/Kernel/TestBundle.php
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Symfony\Bundle\AsseticBundle\Tests\Kernel;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class TestBundle extends Bundle
{
public function getPath()
{
return parent::getPath().'/bundle';
}
}
Expand Up @@ -27,6 +27,7 @@ public function registerBundles()
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \Symfony\Bundle\AsseticBundle\AsseticBundle(),
new TestBundle(),
);
}

Expand Down
@@ -0,0 +1 @@
/* bundle.css */
@@ -1,7 +1,7 @@
<?php $view->extend('::base.html.php') ?>

<?php $view['slots']->start('stylesheets') ?>
<?php foreach($view['assetic']->stylesheets('stylesheet1.css, stylesheet2.css') as $url): ?>
<?php foreach($view['assetic']->stylesheets('stylesheet1.css, stylesheet2.css, @TestBundle/Resources/css/bundle.css') as $url): ?>
<link href="<?php echo $view->escape($url) ?>" type="text/css" rel="stylesheet" />
<?php endforeach; ?>
<?php $view['slots']->stop() ?>
Expand Down
@@ -1,7 +1,7 @@
{% extends '::base.html.twig' %}

{% block stylesheets %}
{% stylesheets 'stylesheet1.css' 'stylesheet2.css' %}
{% stylesheets 'stylesheet1.css' 'stylesheet2.css' '@TestBundle/Resources/css/bundle.css' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
{% endblock %}
Expand Down

0 comments on commit 4ba0e0d

Please sign in to comment.