Search code examples
csssymfonytwigassetic

Assetic stylesheets in Symfony


I have been trying to figure out how to get assetic working with my CSS sources but am having no luck. Two articles I've been tyring to cross-reference are combining and minimising ccs files and assetic asset management. However, the hybrid I've ended up with is the below which isn't working:

    {% stylesheets filter="scssphp" output="css/my.css"
        "http://fonts.googleapis.com/css?family=Great+Vibes" rel="stylesheet" type="text/css">
        "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"
        "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"
        "bundles/app/css/*"
    %}

            <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}

However, when I try running (in Dev) I get an error saying:

Unexpected token "name" of value "rel" in base.html.twig at line 19

PS I have installed leafo and jsqueeze (I have javascripts to do figure out next) with:

$ composer require leafo/scssphp
$ composer require patchwork/jsqueeze:"~1.0"

Solution

  • You have here an error in your code:

    {% stylesheets filter="scssphp" output="css/my.css"
        "http://fonts.googleapis.com/css?family=Great+Vibes" rel="stylesheet" type="text/css">
        "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"
        "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"
        "bundles/app/css/*"
    %}
    

    in every line you have a file that should be rendered. In the second line you have added rel and type. you have to delete that both parameters otherwise its an option for stylesheets. If you delete them it should work.