Explorar el Código

Merge remote branch 'kriswallsmith/assetic/updates'

* kriswallsmith/assetic/updates:
  [AsseticBundle] added twig support for asset packages
  [AsseticBundle] cleaned up php templating support
  [FrameworkBundle] fixed interface and usage in RouterHelper
  [AsseticBundle] fixed twig classes for api changes in assetic
Fabien Potencier hace 14 años
padre
commit
1cd9b5bb49
Se han modificado 19 ficheros con 189 adiciones y 106 borrados
  1. 4 0
      src/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php
  2. 0 1
      src/Symfony/Bundle/AsseticBundle/DependencyInjection/Compiler/TemplatingPass.php
  3. 10 4
      src/Symfony/Bundle/AsseticBundle/Factory/Loader/AsseticHelperFormulaLoader.php
  4. 13 3
      src/Symfony/Bundle/AsseticBundle/Resources/config/templating_php.xml
  5. 31 31
      src/Symfony/Bundle/AsseticBundle/Templating/AsseticHelper.php
  6. 45 0
      src/Symfony/Bundle/AsseticBundle/Templating/DynamicAsseticHelper.php
  7. 0 44
      src/Symfony/Bundle/AsseticBundle/Templating/FormulaLoader.php
  8. 45 0
      src/Symfony/Bundle/AsseticBundle/Templating/StaticAsseticHelper.php
  9. 6 2
      src/Symfony/Bundle/AsseticBundle/Tests/DependencyInjection/AsseticExtensionTest.php
  10. 1 1
      src/Symfony/Bundle/AsseticBundle/Tests/FunctionalTest.php
  11. 4 0
      src/Symfony/Bundle/AsseticBundle/Tests/Resources/Resources/views/layout.html.php
  12. 10 1
      src/Symfony/Bundle/AsseticBundle/Tests/Templating/AsseticHelperTest.php
  13. 3 3
      src/Symfony/Bundle/AsseticBundle/Twig/DynamicExtension.php
  14. 1 1
      src/Symfony/Bundle/AsseticBundle/Twig/DynamicNode.php
  15. 3 3
      src/Symfony/Bundle/AsseticBundle/Twig/DynamicTokenParser.php
  16. 4 4
      src/Symfony/Bundle/AsseticBundle/Twig/StaticExtension.php
  17. 2 1
      src/Symfony/Bundle/AsseticBundle/Twig/StaticNode.php
  18. 3 3
      src/Symfony/Bundle/AsseticBundle/Twig/StaticTokenParser.php
  19. 4 4
      src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php

+ 4 - 0
src/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php

@@ -70,9 +70,13 @@ class AsseticExtension extends Extension
         if ($parameterBag->resolveValue($parameterBag->get('assetic.use_controller'))) {
             $loader->load('controller.xml');
             $container->setParameter('assetic.twig_extension.class', '%assetic.twig_extension.dynamic.class%');
+            $container->getDefinition('assetic.helper.dynamic')->addTag('templating.helper', array('alias' => 'assetic'));
+            $container->remove('assetic.helper.static');
         } else {
             $loader->load('asset_writer.xml');
             $container->setParameter('assetic.twig_extension.class', '%assetic.twig_extension.static.class%');
+            $container->getDefinition('assetic.helper.static')->addTag('templating.helper', array('alias' => 'assetic'));
+            $container->remove('assetic.helper.dynamic');
         }
 
         // register config resources

+ 0 - 1
src/Symfony/Bundle/AsseticBundle/DependencyInjection/Compiler/TemplatingPass.php

@@ -27,7 +27,6 @@ class TemplatingPass implements CompilerPassInterface
             return;
         }
 
-        $am = $container->getDefinition('assetic.asset_manager');
         $engines = $container->getParameterBag()->resolveValue($container->getParameter('templating.engines'));
 
         if (!in_array('twig', $engines)) {

+ 10 - 4
src/Symfony/Bundle/AsseticBundle/Factory/Loader/AsseticHelperFormulaLoader.php

@@ -23,18 +23,18 @@ class AsseticHelperFormulaLoader extends BasePhpFormulaLoader
     protected function registerPrototypes()
     {
         return array(
-            '$view[\'assetic\']->assets(*)'           => array(),
             '$view[\'assetic\']->javascripts(*)'      => array('output' => 'js/*.js'),
             '$view[\'assetic\']->stylesheets(*)'      => array('output' => 'css/*.css'),
-            '$view["assetic"]->assets(*)'             => array(),
+            '$view[\'assetic\']->image(*)'            => array('output' => 'images/*', 'single' => true),
             '$view["assetic"]->javascripts(*)'        => array('output' => 'js/*.js'),
             '$view["assetic"]->stylesheets(*)'        => array('output' => 'css/*.css'),
-            '$view->get(\'assetic\')->assets(*)'      => array(),
+            '$view["assetic"]->image(*)'              => array('output' => 'images/*', 'single' => true),
             '$view->get(\'assetic\')->javascripts(*)' => array('output' => 'js/*.js'),
             '$view->get(\'assetic\')->stylesheets(*)' => array('output' => 'css/*.css'),
-            '$view->get("assetic")->assets(*)'        => array(),
+            '$view->get(\'assetic\')->image(*)'       => array('output' => 'images/*', 'single' => true),
             '$view->get("assetic")->javascripts(*)'   => array('output' => 'js/*.js'),
             '$view->get("assetic")->stylesheets(*)'   => array('output' => 'css/*.css'),
+            '$view->get("assetic")->image(*)'         => array('output' => 'images/*', 'single' => true),
         );
     }
 
@@ -60,6 +60,12 @@ class Helper
         global $_call;
         $_call = func_get_args();
     }
+
+    public function image()
+    {
+        global $_call;
+        $_call = func_get_args();
+    }
 }
 
 class View extends ArrayObject

+ 13 - 3
src/Symfony/Bundle/AsseticBundle/Resources/config/templating_php.xml

@@ -5,17 +5,26 @@
     xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
 
     <parameters>
-        <parameter key="assetic.helper.class">Symfony\Bundle\AsseticBundle\Templating\AsseticHelper</parameter>
+        <parameter key="assetic.helper.dynamic.class">Symfony\Bundle\AsseticBundle\Templating\DynamicAsseticHelper</parameter>
+        <parameter key="assetic.helper.static.class">Symfony\Bundle\AsseticBundle\Templating\StaticAsseticHelper</parameter>
         <parameter key="assetic.php_formula_loader.class">Symfony\Bundle\AsseticBundle\Factory\Loader\AsseticHelperFormulaLoader</parameter>
     </parameters>
 
     <services>
-        <service id="assetic.helper" class="%assetic.helper.class%">
-            <tag name="templating.helper" alias="assetic" />
+        <service id="assetic.helper.dynamic" class="%assetic.helper.dynamic.class%">
             <tag name="assetic.templating.php" />
+            <argument type="service" id="templating.helper.router" />
             <argument type="service" id="assetic.asset_factory" />
             <argument>%assetic.debug%</argument>
         </service>
+
+        <service id="assetic.helper.static" class="%assetic.helper.static.class%">
+            <tag name="assetic.templating.php" />
+            <argument type="service" id="templating.helper.assets" />
+            <argument type="service" id="assetic.asset_factory" />
+            <argument>%assetic.debug%</argument>
+        </service>
+
         <service id="assetic.php_formula_loader" class="%assetic.cached_formula_loader.class%" public="false">
             <tag name="assetic.formula_loader" alias="php" />
             <tag name="assetic.templating.php" />
@@ -23,6 +32,7 @@
             <argument type="service" id="assetic.config_cache" />
             <argument>%kernel.debug%</argument>
         </service>
+
         <service id="assetic.php_formula_loader.real" class="%assetic.php_formula_loader.class%" public="false">
             <tag name="assetic.templating.php" />
             <argument type="service" id="assetic.asset_factory" />

+ 31 - 31
src/Symfony/Bundle/AsseticBundle/Templating/AsseticHelper.php

@@ -11,6 +11,7 @@
 
 namespace Symfony\Bundle\AsseticBundle\Templating;
 
+use Assetic\Asset\AssetInterface;
 use Assetic\Factory\AssetFactory;
 use Symfony\Component\Templating\Helper\Helper;
 
@@ -19,42 +20,30 @@ use Symfony\Component\Templating\Helper\Helper;
  *
  * @author Kris Wallsmith <kris.wallsmith@symfony.com>
  */
-class AsseticHelper extends Helper
+abstract class AsseticHelper extends Helper
 {
     protected $factory;
     protected $debug;
-    protected $defaultJavascriptsOutput;
-    protected $defaultStylesheetsOutput;
-    protected $defaultImageOutput;
 
     /**
      * Constructor.
      *
-     * @param AssetFactory $factory                  The asset factory
-     * @param Boolean      $debug                    The debug mode
-     * @param string       $defaultJavascriptsOutput The default {@link javascripts()} output string
-     * @param string       $defaultStylesheetsOutput The default {@link stylesheets()} output string
-     * @param string       $defaultImageOutput       The default {@link image()} output string
+     * @param AssetFactory $factory The asset factory
+     * @param Boolean      $debug   The debug mode
      */
-    public function __construct(AssetFactory $factory, $debug = false, $defaultJavascriptsOutput = 'js/*.js', $defaultStylesheetsOutput = 'css/*.css', $defaultImageOutput = 'images/*')
+    public function __construct(AssetFactory $factory, $debug = false)
     {
         $this->factory = $factory;
         $this->debug = $debug;
-        $this->defaultJavascriptsOutput = $defaultJavascriptsOutput;
-        $this->defaultStylesheetsOutput = $defaultStylesheetsOutput;
-        $this->defaultImageOutput = $defaultImageOutput;
     }
 
     /**
      * Returns an array of javascript urls.
-     *
-     * This convenience method wraps {@link assets()} and provides a default
-     * output string.
      */
     public function javascripts($inputs = array(), $filters = array(), array $options = array())
     {
         if (!isset($options['output'])) {
-            $options['output'] = $this->defaultJavascriptsOutput;
+            $options['output'] = 'js/*';
         }
 
         return $this->getAssetUrls($inputs, $filters, $options);
@@ -62,14 +51,11 @@ class AsseticHelper extends Helper
 
     /**
      * Returns an array of stylesheet urls.
-     *
-     * This convenience method wraps {@link assets()} and provides a default
-     * output string.
      */
     public function stylesheets($inputs = array(), $filters = array(), array $options = array())
     {
         if (!isset($options['output'])) {
-            $options['output'] = $this->defaultStylesheetsOutput;
+            $options['output'] = 'css/*';
         }
 
         return $this->getAssetUrls($inputs, $filters, $options);
@@ -77,17 +63,16 @@ class AsseticHelper extends Helper
 
     /**
      * Returns an array of one image url.
-     *
-     * This convenience method wraps {@link assets()} and provides a default
-     * output string.
      */
     public function image($inputs = array(), $filters = array(), array $options = array())
     {
         if (!isset($options['output'])) {
-            $options['output'] = $this->defaultImageOutput;
+            $options['output'] = 'images/*';
         }
 
-        return $this->getAssetUrls($inputs, $filters, $options, true);
+        $options['single'] = true;
+
+        return $this->getAssetUrls($inputs, $filters, $options);
     }
 
     /**
@@ -105,11 +90,10 @@ class AsseticHelper extends Helper
      * @param array|string $inputs  An array or comma-separated list of input strings
      * @param array|string $filters An array or comma-separated list of filter names
      * @param array        $options An array of options
-     * @param Boolean      $single  Use only the last input string
      *
      * @return array An array of URLs for the asset
      */
-    private function getAssetUrls($inputs = array(), $filters = array(), array $options = array(), $single = false)
+    private function getAssetUrls($inputs = array(), $filters = array(), array $options = array())
     {
         $explode = function($value)
         {
@@ -128,24 +112,40 @@ class AsseticHelper extends Helper
             $options['debug'] = $this->debug;
         }
 
-        if ($single && 1 < count($inputs)) {
+        if (isset($options['single']) && $options['single'] && 1 < count($inputs)) {
             $inputs = array_slice($inputs, -1);
         }
 
+        if (!isset($options['name'])) {
+            $options['name'] = $this->factory->generateAssetName($inputs, $filters);
+        }
+
         $coll = $this->factory->createAsset($inputs, $filters, $options);
 
         if (!$options['debug']) {
-            return array($coll->getTargetUrl());
+            return array($this->getAssetUrl($coll, $options));
         }
 
         $urls = array();
         foreach ($coll as $leaf) {
-            $urls[] = $leaf->getTargetUrl();
+            $urls[] = $this->getAssetUrl($leaf, array_replace($options, array(
+                'name' => $options['name'].'_'.count($urls),
+            )));
         }
 
         return $urls;
     }
 
+    /**
+     * Returns an URL for the supplied asset.
+     *
+     * @param AssetInterface $asset   An asset
+     * @param array          $options An array of options
+     *
+     * @return string An echo-ready URL
+     */
+    abstract protected function getAssetUrl(AssetInterface $asset, $options = array());
+
     public function getName()
     {
         return 'assetic';

+ 45 - 0
src/Symfony/Bundle/AsseticBundle/Templating/DynamicAsseticHelper.php

@@ -0,0 +1,45 @@
+<?php
+
+/*
+ * This file is part of the Symfony framework.
+ *
+ * (c) Fabien Potencier <fabien@symfony.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\Templating;
+
+use Assetic\Asset\AssetInterface;
+use Assetic\Factory\AssetFactory;
+use Symfony\Bundle\FrameworkBundle\Templating\Helper\RouterHelper;
+
+/**
+ * The dynamic "assetic" templating helper.
+ *
+ * @author Kris Wallsmith <kris.wallsmith@symfony.com>
+ */
+class DynamicAsseticHelper extends AsseticHelper
+{
+    private $routerHelper;
+
+    /**
+     * Constructor.
+     *
+     * @param RouterHelper $routerHelper The router helper
+     * @param AssetFactory $factory      The asset factory
+     * @param Boolean      $debug        The debug mode
+     */
+    public function __construct(RouterHelper $routerHelper, AssetFactory $factory, $debug = false)
+    {
+        $this->routerHelper = $routerHelper;
+
+        parent::__construct($factory, $debug);
+    }
+
+    protected function getAssetUrl(AssetInterface $asset, $options = array())
+    {
+        return $this->routerHelper->generate('assetic_'.$options['name']);
+    }
+}

+ 0 - 44
src/Symfony/Bundle/AsseticBundle/Templating/FormulaLoader.php

@@ -1,44 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony framework.
- *
- * (c) Fabien Potencier <fabien@symfony.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\Templating;
-
-use Assetic\Factory\Loader\FormulaLoaderInterface;
-use Assetic\Factory\Resource\ResourceInterface;
-
-/**
- * Loads formulae from PHP templates.
- *
- * @author Kris Wallsmith <kris.wallsmith@symfony.com>
- */
-class FormulaLoader implements FormulaLoaderInterface
-{
-    public function load(ResourceInterface $resource)
-    {
-        $tokens = token_get_all($resource->getContent());
-
-        /**
-         * @todo Find and extract asset formulae from calls to the following:
-         *
-         *  * $view['assetic']->assets(...)
-         *  * $view['assetic']->javascripts(...)
-         *  * $view['assetic']->stylesheets(...)
-         *  * $view->get('assetic')->assets(...)
-         *  * $view->get('assetic')->javascripts(...)
-         *  * $view->get('assetic')->stylesheets(...)
-         *
-         * The loader will also need to be aware of debug mode and the default
-         * output strings associated with each method.
-         */
-
-        return array();
-    }
-}

+ 45 - 0
src/Symfony/Bundle/AsseticBundle/Templating/StaticAsseticHelper.php

@@ -0,0 +1,45 @@
+<?php
+
+/*
+ * This file is part of the Symfony framework.
+ *
+ * (c) Fabien Potencier <fabien@symfony.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\Templating;
+
+use Assetic\Asset\AssetInterface;
+use Assetic\Factory\AssetFactory;
+use Symfony\Component\Templating\Helper\AssetsHelper;
+
+/**
+ * The static "assetic" templating helper.
+ *
+ * @author Kris Wallsmith <kris.wallsmith@symfony.com>
+ */
+class StaticAsseticHelper extends AsseticHelper
+{
+    private $assetsHelper;
+
+    /**
+     * Constructor.
+     *
+     * @param AssetsHelper $assetsHelper The assets helper
+     * @param AssetFactory $factory      The asset factory
+     * @param Boolean      $debug        The debug mode
+     */
+    public function __construct(AssetsHelper $assetsHelper, AssetFactory $factory, $debug = false)
+    {
+        $this->assetsHelper = $assetsHelper;
+
+        parent::__construct($factory, $debug);
+    }
+
+    protected function getAssetUrl(AssetInterface $asset, $options = array())
+    {
+        return $this->assetsHelper->getUrl($asset->getTargetUrl(), isset($options['package']) ? $options['package'] : null);
+    }
+}

+ 6 - 2
src/Symfony/Bundle/AsseticBundle/Tests/DependencyInjection/AsseticExtensionTest.php

@@ -16,6 +16,7 @@ use Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler\CheckYuiFilterPass
 use Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler\CheckClosureFilterPass;
 use Symfony\Component\DependencyInjection\Container;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Definition;
 use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
 use Symfony\Component\DependencyInjection\Scope;
 use Symfony\Component\HttpFoundation\Request;
@@ -52,11 +53,14 @@ class AsseticExtensionTest extends \PHPUnit_Framework_TestCase
         $this->container = new ContainerBuilder();
         $this->container->addScope(new Scope('request'));
         $this->container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request');
+        $this->container->register('templating.helper.assets', $this->getMockClass('Symfony\\Component\\Templating\\Helper\\AssetsHelper'));
+        $this->container->register('templating.helper.router', $this->getMockClass('Symfony\\Bundle\\FrameworkBundle\\Templating\\Helper\\RouterHelper'))
+            ->addArgument(new Definition($this->getMockClass('Symfony\\Component\\Routing\\RouterInterface')));
         $this->container->register('twig', 'Twig_Environment');
+        $this->container->setParameter('kernel.bundles', array());
+        $this->container->setParameter('kernel.cache_dir', __DIR__);
         $this->container->setParameter('kernel.debug', false);
         $this->container->setParameter('kernel.root_dir', __DIR__);
-        $this->container->setParameter('kernel.cache_dir', __DIR__);
-        $this->container->setParameter('kernel.bundles', array());
     }
 
     /**

+ 1 - 1
src/Symfony/Bundle/AsseticBundle/Tests/FunctionalTest.php

@@ -106,7 +106,7 @@ class FunctionalTest extends \PHPUnit_Framework_TestCase
     {
         // totals include assets defined in both php and twig templates
         return array(
-            array(true, 8),
+            array(true, 6),
             array(false, 3),
         );
     }

+ 4 - 0
src/Symfony/Bundle/AsseticBundle/Tests/Resources/Resources/views/layout.html.php

@@ -11,3 +11,7 @@
         <script src="<?php echo $view->escape($url) ?>"></script>
     <?php endforeach; ?>
 <?php $view['slots']->stop() ?>
+
+<?php foreach ($view['assetic']->image('logo.png') as $url): ?>
+    <img src="<?php echo $view->escape($url) ?>">
+<?php endforeach; ?>

+ 10 - 1
src/Symfony/Bundle/AsseticBundle/Tests/Templating/AsseticHelperTest.php

@@ -12,6 +12,7 @@
 namespace Symfony\Bundle\AsseticBundle\Tests\Templating;
 
 use Assetic\Asset\AssetCollection;
+use Assetic\Asset\AssetInterface;
 use Assetic\Asset\StringAsset;
 use Assetic\Factory\AssetFactory;
 use Symfony\Bundle\AsseticBundle\Templating\AsseticHelper;
@@ -30,7 +31,7 @@ class AsseticHelperTest extends \PHPUnit_Framework_TestCase
      */
     public function testUrls($debug, $count, $message)
     {
-        $helper = new AsseticHelper(new AssetFactory('/foo', $debug), $debug);
+        $helper = new AsseticHelperForTest(new AssetFactory('/foo', $debug), $debug);
         $urls = $helper->javascripts(array('js/jquery.js', 'js/jquery.plugin.js'));
 
         $this->assertInternalType('array', $urls, '->javascripts() returns an array');
@@ -45,3 +46,11 @@ class AsseticHelperTest extends \PHPUnit_Framework_TestCase
         );
     }
 }
+
+class AsseticHelperForTest extends AsseticHelper
+{
+    protected function getAssetUrl(AssetInterface $asset, $options = array())
+    {
+        return $asset->getTargetUrl();
+    }
+}

+ 3 - 3
src/Symfony/Bundle/AsseticBundle/Twig/DynamicExtension.php

@@ -24,9 +24,9 @@ class DynamicExtension extends AsseticExtension
     public function getTokenParsers()
     {
         return array(
-            new DynamicTokenParser($this->factory, 'javascripts', 'js/*.js', $this->debug),
-            new DynamicTokenParser($this->factory, 'stylesheets', 'css/*.css', $this->debug),
-            new DynamicTokenParser($this->factory, 'image', 'images/*', $this->debug, true),
+            new DynamicTokenParser($this->factory, 'javascripts', 'js/*.js', $this->debug, false, array('package')),
+            new DynamicTokenParser($this->factory, 'stylesheets', 'css/*.css', $this->debug, false, array('package')),
+            new DynamicTokenParser($this->factory, 'image', 'images/*', $this->debug, true, array('package')),
         );
     }
 }

+ 1 - 1
src/Symfony/Bundle/AsseticBundle/Twig/DynamicNode.php

@@ -28,7 +28,7 @@ class DynamicNode extends AsseticNode
         return new \Twig_Node_Expression_Function(
             new \Twig_Node_Expression_Name('path', $body->getLine()),
             new \Twig_Node(array(
-                new \Twig_Node_Expression_Constant('assetic_'.$this->getAttribute('asset_name'), $body->getLine()),
+                new \Twig_Node_Expression_Constant('assetic_'.$this->getAttribute('name'), $body->getLine()),
             )),
             $body->getLine()
         );

+ 3 - 3
src/Symfony/Bundle/AsseticBundle/Twig/DynamicTokenParser.php

@@ -14,14 +14,14 @@ namespace Symfony\Bundle\AsseticBundle\Twig;
 use Assetic\Extension\Twig\AsseticTokenParser;
 
 /**
- * Parses the {% assets %} tag.
+ * Parses an Assetic tag.
  *
  * @author Kris Wallsmith <kris.wallsmith@symfony.com>
  */
 class DynamicTokenParser extends AsseticTokenParser
 {
-    static protected function createNode(\Twig_NodeInterface $body, array $sourceUrls, $targetUrl, array $filterNames, $assetName, $debug = false, $lineno = 0, $tag = null)
+    static protected function createNode(\Twig_NodeInterface $body, array $inputs, array $filters, array $attributes, $lineno = 0, $tag = null)
     {
-        return new DynamicNode($body, $sourceUrls, $targetUrl, $filterNames, $assetName, $debug, $lineno, $tag);
+        return new DynamicNode($body, $inputs, $filters, $attributes, $lineno, $tag);
     }
 }

+ 4 - 4
src/Symfony/Bundle/AsseticBundle/Twig/StaticExtension.php

@@ -15,7 +15,7 @@ use Assetic\Extension\Twig\AsseticExtension;
 use Assetic\Factory\AssetFactory;
 
 /**
- * The Static extension is used when use_controllers is disabled.
+ * The static extension is used when use_controllers is disabled.
  *
  * @author Kris Wallsmith <kris.wallsmith@symfony.com>
  */
@@ -24,9 +24,9 @@ class StaticExtension extends AsseticExtension
     public function getTokenParsers()
     {
         return array(
-            new StaticTokenParser($this->factory, 'javascripts', 'js/*.js', $this->debug),
-            new StaticTokenParser($this->factory, 'stylesheets', 'css/*.css', $this->debug),
-            new StaticTokenParser($this->factory, 'image', 'images/*', $this->debug, true),
+            new StaticTokenParser($this->factory, 'javascripts', 'js/*.js', $this->debug, false, array('package')),
+            new StaticTokenParser($this->factory, 'stylesheets', 'css/*.css', $this->debug, false, array('package')),
+            new StaticTokenParser($this->factory, 'image', 'images/*', $this->debug, true, array('package')),
         );
     }
 }

+ 2 - 1
src/Symfony/Bundle/AsseticBundle/Twig/StaticNode.php

@@ -28,7 +28,8 @@ class StaticNode extends AsseticNode
         return new \Twig_Node_Expression_Function(
             new \Twig_Node_Expression_Name('asset', $body->getLine()),
             new \Twig_Node(array(
-                new \Twig_Node_Expression_Constant($this->getAttribute('target_url'), $body->getLine()),
+                new \Twig_Node_Expression_Constant($this->getAttribute('output'), $body->getLine()),
+                new \Twig_Node_Expression_Constant($this->hasAttribute('package') ? $this->getAttribute('package') : null, $body->getLine()),
             )),
             $body->getLine()
         );

+ 3 - 3
src/Symfony/Bundle/AsseticBundle/Twig/StaticTokenParser.php

@@ -14,14 +14,14 @@ namespace Symfony\Bundle\AsseticBundle\Twig;
 use Assetic\Extension\Twig\AsseticTokenParser;
 
 /**
- * Parses the {% assets %} tag.
+ * Parses an Assetic tag.
  *
  * @author Kris Wallsmith <kris.wallsmith@symfony.com>
  */
 class StaticTokenParser extends AsseticTokenParser
 {
-    static protected function createNode(\Twig_NodeInterface $body, array $sourceUrls, $targetUrl, array $filterNames, $assetName, $debug = false, $lineno = 0, $tag = null)
+    static protected function createNode(\Twig_NodeInterface $body, array $inputs, array $filters, array $attributes, $lineno = 0, $tag = null)
     {
-        return new StaticNode($body, $sourceUrls, $targetUrl, $filterNames, $assetName, $debug, $lineno, $tag);
+        return new StaticNode($body, $inputs, $filters, $attributes, $lineno, $tag);
     }
 }

+ 4 - 4
src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php

@@ -12,7 +12,7 @@
 namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;
 
 use Symfony\Component\Templating\Helper\Helper;
-use Symfony\Component\Routing\RouterInterface;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 
 /**
  * RouterHelper manages links between pages in a template context.
@@ -26,11 +26,11 @@ class RouterHelper extends Helper
     /**
      * Constructor.
      *
-     * @param RouterInterface $router A Router instance
+     * @param UrlGeneratorInterface $router A Router instance
      */
-    public function __construct(RouterInterface $router)
+    public function __construct(UrlGeneratorInterface $router)
     {
-        $this->generator = $router->getGenerator();
+        $this->generator = $router;
     }
 
     /**