-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi and thanks for documenting this, it really helps.
i think there are two glitches in your config:

you duplicate "bundles" by having it both in write_to and and in your
stylesheet tag. the most simple use case is probably:

write_to: %kernel.root_dir%/../web
...
output='all.css'

if you want assetic to do more than concatenate the files, you need to
specify a filter. you just enable them in your config, but assetic only
uses them when they are specified in the stylesheets tag:

{% stylesheets output='all.css' filter='less' '@PlaysoftHR/...f.less' %}

check the dependency injection file to see what you can configure - you
will need to specify something for some of the filters. some just need
the necessary 3rd party installed and if you do it at the default
location, they just work

vendor/symfony/src/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php

cheers,david

Am 01.04.2011 01:04, schrieb Wizermil:
> Hi,
> 
> I confirm it was a mistake in my code, my bad.
> 
> I didn't write the right path in output attribute. I forget about the
> system folder "web/bundles" (generated automatically by app/console
> assets:install web) I thought it was handled by the framework but not :
> (.
> Whatever, I can explain how I fixed it. Maybe it can help other devs
> waiting for awesome official Symfony documentation.
> 
> The lines below describe what I did to shrink the css files hosted in
> my bundle (PlaysoftHR) in the folder public/css/* and in an extra
> folders called public/lib/* (jquery-ui, ...).
> 
> 1. Setup app/config.yaml
>       Add "write_to:       %kernel.root_dir%/../web/bundles" to the assetic
> section.
>       Example:
>       assetic:
>           debug:          %kernel.debug%
>           use_controller: false
>           write_to:       %kernel.root_dir%/../web/bundles
>           filters:
>               cssrewrite: ~
>               closure:    ~
> 2. About Twig Syntax
>       You can use the {% stylesheets %}, {% javascripts %} and {% image %}
> extensions depending of what you want to do.
>       Example to Shrink CSS:
>               {% stylesheets output='bundles/playsofthr/css/all.css' 
> '@PlaysoftHR/
> Resources/public/css/hr.css' '@PlaysoftHR/Resources/public/lib/
> shjs-0.6/sh_style.css' '@PlaysoftHR/Resources/public/lib/jquery-
> ui-1.8.11.custom/css/ui-lightness/jquery-ui-1.8.11.custom.css'
> '@PlaysoftHR/Resources/public/lib/CLEditor1_3_0/jquery.cleditor.css'
> %}
>                       <link href="{{ asset_url }}" type="text/css" 
> rel="stylesheet" />
>               {% endstylesheets %}
>       Note: You have to be careful about the "output" to be sure that it
> will be compliant with Symfony2 bundles public resources path "web/
> bundles/..."
> 3. Generate assets using the console
>       Debug Env: app/console assetic:dump
>       Prod Env: app/console --no-debug --env=prod assetic:dump
> 4. Check
>       Double check that you can see the files you define in output of the
> twig block
> 5. Debug
>       Finally using any Developer Tool (Chrome, Firefox, DragonFly ...) you
> have to verify that you are able to download the file without 404
> errors. If it doesn't work it probably means that the path you defined
> in the output is wrong like I did the first time ;)
> 
> I hope that it will help other devs.
> 
> Cheers,
> 
> Mathieu
> 
> On Mar 31, 7:11 pm, Wizermil <mathieu.gar...@gmail.com> wrote:
>> Hi Albert,
>>
>> Thanks for the reply.
>>
>> When I use this syntax:
>> {% assets 'mybundle/css/*.css' output='css/all.css' %}
>>     {{ asset_url }}
>> {% endassets %}
>> It throw an exception:
>> Unknown tag name "assets" in "PlaysoftHR::layout.html.twig" line 6
>>
>> That's why I checked in assetic to see that the method stylesheets is
>> available in twig. Moreover it works in debug environment.
>>
>> But maybe I'm doing something wrong I'll check this evening.
>>
>> Regards,
>>
>> Mathieu
>>
>> On Mar 31, 7:22 am, Albert Jessurum <ajessu...@gmail.com> wrote:
>>
>>
>>
>>
>>
>>
>>
>>>> In my view I have the following code to generate assets:
>>
>>>> File: @MyBundle/Resources/views/layout.twig.html
>>
>>>> {% assets 'mybundle/css/*.css' output='css/all.css' %}
>>>>     {{ asset_url }}
>>>> {% endassets %}
>>
>>>> You're missing the @ when refering to a resource.
>>
>>> It should be {% assets '@MyBundle/Resources/css/*.css'  ... %}
> 

- -- 
Liip AG // Agile Web Development // T +41 26 422 25 11
CH-1700 Fribourg // PGP 0xA581808B // www.liip.ch
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2W8TkACgkQqBnXnqWBgItCHQCfQK/q3RqAcf3kjxokPa3UTwZE
/OYAoIuqSsmPVGRDW2ePKOfe8cNyyn2W
=RU20
-----END PGP SIGNATURE-----

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to