Sass / Compass in Symfony2



我正在尝试使用带有symfony2和asseticbundle的scs文件。

我的配置yml资产部分:

assetic:
debug:          %kernel.debug%
use_controller: false
bundles:        []
filters:
    sass:    ~
    compass: ~
    #closure:
    #    jar: "%kernel.root_dir%/Resources/java/compiler.jar"
    #yui_css:
    #    jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"

my-base.html.twig:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>{% block title %}Welcome!{% endblock %}</title>
    {% block stylesheets %}
        {% stylesheets filters="compass"
            "@TestBundle/Resources/public/sass/main.scss"
        %}
        <link rel="stylesheet" href="{{ asset_url }}" />
        {% endstylesheets %}
    {% endblock %}
    <link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
</head>
<body ng-app="myapp">
{% block body %}{% endblock %}
{% block javascripts %}
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
    <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
    <script src="{{ asset('js/app.js' ) }}" />
{% endblock %}

TestBundle/Resources/public/sass/main.css 中的my main.scss

$background: #000;
body{
    background-color:$background;
}

这是我得到的错误:

Unexpected token "name" of value "filters" in app/Resources/views/base.html.twig at line 7

在我的案例中,问题出现在filters单词中,该单词必须是filter。尝试更改

{% stylesheets filters="compass"
  "@TestBundle/Resources/public/sass/main.scss"
%}

{% stylesheets filter="compass"
   "@TestBundle/Resources/public/sass/main.scss"
%}

最新更新