我正在尝试使用带有symfony2和asseticbundle的scss文件。
我的config.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"
我的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.scss中的main.scss
$background: #000;
body{
background-color:$background;
}
这是我得到的错误:
Unexpected token "name" of value "filters" in app/Resources/views/base.html.twig at line 7
答案 0 :(得分:5)
在我的情况下,问题出在过滤器一词中,必须是过滤器。尝试改变
{% stylesheets filters="compass"
"@TestBundle/Resources/public/sass/main.scss"
%}
到
{% stylesheets filter="compass"
"@TestBundle/Resources/public/sass/main.scss"
%}