0

我对此很陌生,所以我会提供尽可能多的细节:

使用 Mac OSX 10.7.4

今天安装:TextMate 1.5.11 RVM 1.15.5 by Wayne Seguin GCC 10.7 Ruby 1.9.3 Rails 3.2.8 Haml 3.1.7 Sass 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 文件的类似问题——它们是否需要位于特定文件夹中才能让终端找到它们?

而且..不确定为什么 --trace 不起作用...

有人可以建议我如何解决这个问题吗?我只熟悉 HTML/CSS,并被我的团队要求学习 Haml/Sass。

4

3 回答 3

1

input.haml应该存在并且应该是一个haml文件。output.html是存储输出的位置(如果存在,将被覆盖)

这些文件可以在您想要的任何位置,但如果它们不在当前目录中,您需要相应地调整路径。

同样对于 sassstyle.scss必须存在并且生成的 CSS 将输出到 style.css

于 2012-08-19T18:56:44.390 回答
0

您没有--trace正确使用命令。在 UNIX 命令行中,在命令行中运行的程序(在命令行界面中也称为 cli )使用以or开头的称为标志的选项。因此,在没有使用过 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也可能带来有用的信息。

于 2012-08-19T18:34:58.820 回答
0

使用 Google Chat 屏幕共享,我的在线同事查看了我的终端活动,然后给了我一些使用命令,以便可以找到文件。接下来,他们让我在 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
于 2012-08-21T14:34:55.803 回答