如何解决语法错误:只能在文档的根目录中定义函数。用Compass编译时

时间:2011-11-21 15:48:07

标签: extjs themes sass compass-sass

我正在尝试为ext js 4编译对.scss文件所做的更改。当我编译文件罗盘输出时。

Syntax error: Functions may only be defined at the root of a document.
        on line 115 of G:/Ruby/bin/resources/themes/stylesheets/ext4/default/mixins/_frame.scss
        from line 4 of G:/Ruby/bin/resources/themes/stylesheets/ext4/default/_mixins.scss
        from line 9 of G:/Ruby/bin/resources/themes/stylesheets/ext4/default/_all.scss
        from line 118 of G:/Ruby/bin/resources/sass/ext-all-gray.scss

Backtrace:
G:/Ruby/bin/resources/themes/stylesheets/ext4/default/mixins/_frame.scss:115
G:/Ruby/bin/resources/themes/stylesheets/ext4/default/_mixins.scss:4
G:/Ruby/bin/resources/themes/stylesheets/ext4/default/_all.scss:9
G:/Ruby/bin/resources/sass/ext-all-gray.scss:118
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/check_nesting.rb:12:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `map'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/check_nesting.rb:26:in `visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:39:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/check_nesting.rb:14:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `map'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/check_nesting.rb:26:in `visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:39:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/check_nesting.rb:14:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `map'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/check_nesting.rb:26:in `visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `block in visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:70:in `visit_if'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/check_nesting.rb:14:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `map'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/check_nesting.rb:26:in `visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:39:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/check_nesting.rb:14:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `map'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/check_nesting.rb:26:in `visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `block in visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/check_nesting.rb:33:in `visit_root'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/check_nesting.rb:14:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:24:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:143:in `visit_import'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:18:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:144:in `block in visit_import'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:144:in `map'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:144:in `visit_import'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:18:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:144:in `block in visit_import'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:144:in `map'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:144:in `visit_import'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:18:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `map'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `block in visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:47:in `visit_root'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:18:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:7:in `visit'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/tree/root_node.rb:20:in `render'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/engine.rb:300:in `_render'
G:/Ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.10/lib/sass/engine.rb:247:in `render'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/compiler.rb:130:in `block (2 levels) in compile'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/compiler.rb:116:in `timed'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/compiler.rb:129:in `block in compile'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/logger.rb:45:in `red'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/compiler.rb:128:in `compile'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/compiler.rb:108:in `compile_if_required'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/compiler.rb:95:in `block (2 levels) in run'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/compiler.rb:93:in `each'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/compiler.rb:93:in `block in run'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/compiler.rb:116:in `timed'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/compiler.rb:92:in `run'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/commands/update_project.rb:36:in `perform'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/commands/base.rb:18:in `execute'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/commands/project_base.rb:19:in `execute'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/exec/sub_command_ui.rb:43:in `perform!'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/exec/sub_command_ui.rb:15:in `run!'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/bin/compass:25:in `block in <top (required)>'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/bin/compass:39:in `call'
G:/Ruby/lib/ruby/gems/1.9.1/gems/compass-0.11.1/bin/compass:39:in `<top (required)>'
G:/Ruby/bin/compass:19:in `load'
G:/Ruby/bin/compass:19:in `<main>'

body:before {
  white-space: pre;
  font-family: monospace;
  content: "Syntax error: Functions may only be defined at the root of a document.\A         on line 115 of G:/Ruby/bin/resources/themes/stylesheets/ext4/default/mixins/_frame.scss\A         from line 4 of G:/Ruby/bin/resources/themes/stylesheets/ext4/default/_mixins.scss\A         from line 9 of G:/Ruby/bin/resources/themes/stylesheets/ext4/default/_all.scss\A         from line 118 of G:/Ruby/bin/resources/sass/ext-all-gray.scss"; }

我一直在互联网上寻求帮助,并提示我发现的所有内容都是使用sass版本3.1.1。我试过了,没有变化。

2 个答案:

答案 0 :(得分:1)

基本上,这意味着您使用的代码或某些第三方代码在范围内而不是在根级别定义函数。如果在包含函数定义的文件范围内执行@import,则可能会意外地获取此信息。在这种情况下,您通常需要做的是在根级别@import@include mixins或插入相关范围内的函数调用。

有可能降级SASS以解决此问题,但长期来看,如果我理解正确,这是SASS不支持的功能。

答案 1 :(得分:0)

您必须卸载指南针和sass,重新安装sass版本3.1.1,然后重新安装指南针。这对我有用。