schmittjoh/twig.js — Issue #20: twig.js causes error in AsseticBundle
Author: tarjei
Created: 2012-03-05 20:08:34+00:00
State: open

Hi, I got configured assetic like this:

```yaml
assetic:
debug: %kernel.debug%
use_controller: false
filters:
cssrewrite: ~

closure:
jar: %kernel.root_dir%/Resources/java/compiler.jar
yui_js:
jar: %kernel.root_dir%/Resources/java/yuicompressor.jar
yui_css:
jar: %kernel.root_dir%/Resources/java/yuicompressor.jar
```

(indents changed to make post nicer - they are not wrong in the config file).

And my template like this:
```twig
{% javascripts "@MyAdminBundle/Resources/views/Resource/videoView.html.twig"
filter="twig_js, ?yui_js" %}

{% endjavascripts %}
```
Which generates the following stacktrace in _dev:

[exception] 500 | Internal Server Error | Exception
[message] SplObjectStorage::serialize() must return a string or NULL
[1] Exception: SplObjectStorage::serialize() must return a string or NULL
at n/a
in /home/tarjei/myproject/vendor/assetic/src/Assetic/Asset/AssetCache.php line 138

at serialize()
in /home/tarjei/myproject/vendor/assetic/src/Assetic/Asset/AssetCache.php line 0

at Assetic\Asset\AssetCache::getCacheKey(object(Assetic\Asset\FileAsset), null, 'dump')
in /home/tarjei/myproject/vendor/assetic/src/Assetic/Asset/AssetCache.php line 62

at Assetic\Asset\AssetCache->dump()
in /home/tarjei/myproject/vendor/bundles/Symfony/Bundle/AsseticBundle/Controller/AsseticController.php line 80

at Symfony\Bundle\AsseticBundle\Controller\AsseticController->render('4bc396c', '0')
in line

at call_user_func_array(array(object(Symfony\Bundle\AsseticBundle\Controller\AsseticController), 'render'), array('4bc396c', '0'))
in /home/tarjei/myproject/app/cache/dev/classes.php line 3905

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Symfony\Component\HttpFoundation\Request), '1')
in /home/tarjei/myproject/app/cache/dev/classes.php line 3875

at Symfony\Component\HttpKernel\HttpKernel->handle(object(Symfony\Component\HttpFoundation\Request), '1', true)
in /home/tarjei/myproject/app/cache/dev/classes.php line 4852

at Symfony\Bundle\FrameworkBundle\HttpKernel->handle(object(Symfony\Component\HttpFoundation\Request), '1', true)
in /home/tarjei/myproject/app/bootstrap.php.cache line 547

at Symfony\Component\HttpKernel\Kernel->handle(object(Symfony\Component\HttpFoundation\Request))
in /home/tarjei/myproject/web/app_dev.php line 26

[2] Exception: SplObjectStorage::serialize() must return a string or NULL
at n/a
in /home/tarjei/myproject/vendor/assetic/src/Assetic/Asset/AssetCache.php line 138

at serialize()
in /home/tarjei/myproject/vendor/assetic/src/Assetic/Asset/AssetCache.php line 0

at Assetic\Asset\AssetCache::getCacheKey(object(Assetic\Asset\FileAsset), null, 'dump')
in /home/tarjei/myproject/vendor/assetic/src/Assetic/Asset/AssetCache.php line 62

at Assetic\Asset\AssetCache->dump()
in /home/tarjei/myproject/vendor/bundles/Symfony/Bundle/AsseticBundle/Controller/AsseticController.php line 80

at Symfony\Bundle\AsseticBundle\Controller\AsseticController->render('4bc396c', '0')
in line

at call_user_func_array(array(object(Symfony\Bundle\AsseticBundle\Controller\AsseticController), 'render'), array('4bc396c', '0'))
in /home/tarjei/myproject/app/cache/dev/classes.php line 3905

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Symfony\Component\HttpFoundation\Request), '1')
in /home/tarjei/myproject/app/cache/dev/classes.php line 3875

at Symfony\Component\HttpKernel\HttpKernel->handle(object(Symfony\Component\HttpFoundation\Request), '1', true)
in /home/tarjei/myproject/app/cache/dev/classes.php line 4852

at Symfony\Bundle\FrameworkBundle\HttpKernel->handle(object(Symfony\Component\HttpFoundation\Request), '1', true)
in /home/tarjei/myproject/app/bootstrap.php.cache line 547

at Symfony\Component\HttpKernel\Kernel->handle(object(Symfony\Component\HttpFoundation\Request))
in /home/tarjei/myproject/web/app_dev.php line 26

[3] Exception: SplObjectStorage::serialize() must return a string or NULL
at n/a
in /home/tarjei/myproject/vendor/assetic/src/Assetic/Asset/AssetCache.php line 138

at serialize()
in /home/tarjei/myproject/vendor/assetic/src/Assetic/Asset/AssetCache.php line 0

at Assetic\Asset\AssetCache::getCacheKey(object(Assetic\Asset\FileAsset), null, 'dump')
in /home/tarjei/myproject/vendor/assetic/src/Assetic/Asset/AssetCache.php line 62

at Assetic\Asset\AssetCache->dump()
in /home/tarjei/myproject/vendor/bundles/Symfony/Bundle/AsseticBundle/Controller/AsseticController.php line 80

at Symfony\Bundle\AsseticBundle\Controller\AsseticController->render('4bc396c', '0')
in line

at call_user_func_array(array(object(Symfony\Bundle\AsseticBundle\Controller\AsseticController), 'render'), array('4bc396c', '0'))
in /home/tarjei/myproject/app/cache/dev/classes.php line 3905

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Symfony\Component\HttpFoundation\Request), '1')
in /home/tarjei/myproject/app/cache/dev/classes.php line 3875

at Symfony\Component\HttpKernel\HttpKernel->handle(object(Symfony\Component\HttpFoundation\Request), '1', true)
in /home/tarjei/myproject/app/cache/dev/classes.php line 4852

at Symfony\Bundle\FrameworkBundle\HttpKernel->handle(object(Symfony\Component\HttpFoundation\Request), '1', true)
in /home/tarjei/myproject/app/bootstrap.php.cache line 547

at Symfony\Component\HttpKernel\Kernel->handle(object(Symfony\Component\HttpFoundation\Request))
in /home/tarjei/myproject/web/app_dev.php line 26

I think this is due to Twig.js keeping a reference to a simplexml object somewhere - but I have no idea where. I tried to find it but got lost.