我对这方面很陌生,所以我会尽可能多地提供细节:
使用Mac OSX 10.7.4
今天安装:TextMate 1.5.11RVM 1.15.5由Wayne SeguinGCC 10.7红宝石1.9.3轨道3.2.8哈姆尔3.1.7Sass 3.2.1
哈姆尔指令:
要从命令行运行Haml,只需使用
haml input.haml output.html
当我输入上述命令时,我的终端响应:
Errno::ENOENT: No such file or directory - input.haml
Use --trace for backtrace.
当我输入时:
--trace
它返回:
-bash: --trace: command not found
与Sass有类似问题:
$ sass --watch style.scss:style.css
>>> Sass is watching for changes. Press Ctrl-C to stop.
Errno::ENOENT: No such file or directory - style.scss
Use --trace for backtrace.
我需要先创建input.haml和output.haml文件并将它们放在某个目录中吗?如果是,有人能给我一个文件夹需要去的非常具体的路径吗?
Sass文件也有类似的问题——它们需要在特定的文件夹中才能被终端定位吗?
而且。。不确定为什么跟踪不起作用。。。
有人能建议我如何解决这个问题吗?我只熟悉HTML/CSS,我的团队要求我学习Haml/Sass。
input.haml
应该存在并且应该是一个haml文件。output.html
是存储输出的位置(如果存在,则会被覆盖)
这些文件可以放在你想要的任何地方,但如果它们不在当前目录中,你需要相应地调整路径。
类似地,对于sass,style.scss
必须存在,并且生成的CSS将输出到style.CSS
您没有正确使用--trace
命令。在UNIX命令行中,在命令行中运行的程序(在命令行界面中也称为cli)使用以-
或--
开头的标志选项。因此,在没有使用过HAML代码的情况下,我看到这是一个像这样使用的标志:
➜ ~ uname -a
Darwin Angel.local 12.0.0 Darwin Kernel Version 12.0.0: Sun Jun 24 23:00:16 PDT 2012; root:xnu-2050.7.9~1/RELEASE_X86_64 x86_64
➜ ~ cat > test.haml
#content
.left.column
%h2 Welcome to our site!
%p= print_information
.right.column
= render :partial => "sidebar"
^C
➜ ~ haml test.haml
Exception on line 4: undefined local variable or method `print_information' for #<Object:0x007f9844896cd0>
Use --trace for backtrace.
Use --trace for backtrace.
➜ ~ haml test.haml --trace
test.haml:4:in `block in render': undefined local variable or method `print_information' for #<Object:0x007fd83b9f8650> (NameError)
from /Users/atma/.rvm/gems/ruby-1.9.3-p194/gems/haml-3.1.7/lib/haml/engine.rb:191:in `eval'
from /Users/atma/.rvm/gems/ruby-1.9.3-p194/gems/haml-3.1.7/lib/haml/engine.rb:191:in `render'
from /Users/atma/.rvm/gems/ruby-1.9.3-p194/gems/haml-3.1.7/lib/haml/exec.rb:281:in `process_result'
from /Users/atma/.rvm/gems/ruby-1.9.3-p194/gems/haml-3.1.7/lib/haml/exec.rb:41:in `parse'
from /Users/atma/.rvm/gems/ruby-1.9.3-p194/gems/haml-3.1.7/lib/haml/exec.rb:21:in `parse!'
from /Users/atma/.rvm/gems/ruby-1.9.3-p194/gems/haml-3.1.7/bin/haml:9:in `<top (required)>'
from /Users/atma/.rvm/gems/ruby-1.9.3-p194/bin/haml:19:in `load'
from /Users/atma/.rvm/gems/ruby-1.9.3-p194/bin/haml:19:in `<main>'
from /Users/atma/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/atma/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
➜ ~
除此之外,我刚刚通过RVM在MacOSX 10.8上安装了haml gem,运行良好。运行ruby filename.haml
可能还会带来一条有用的消息。
使用谷歌聊天屏幕共享,我的在线同事查看了我的终端活动,然后给了我一些使用命令,以便找到文件。接下来,他们让我在input.haml文档中放一行简单的"Hello World",用于测试目的。
今天,haml现在可以找到文件,当我给它关于input.haml和output.html文件的命令时,它成功地将数据从输入传输到输出。
所以问题是我不知道如何在终端中找到正确的目录。
Doras-MacBook-Pro:~ whisperland$ cd/Users/whisperland/documents/ haml input.haml
-bash: cd/Users/whisperland/documents/: No such file or directory
Doras-MacBook-Pro:~ whisperland$ cd documents
Doras-MacBook-Pro:documents whisperland$ ls
document.haml output.html
input.haml typography.rtf
Doras-MacBook-Pro:documents whisperland$ haml input.haml
hello world
Doras-MacBook-Pro:documents whisperland$ haml input.haml output.html