无法使用 Windows 上的 "erb2haml" gem 将 html.erb 转换为 haml

Can't convert html.erb's to haml with the "erb2haml" gem on Windows

已解决。看看我下面的回答。

我的问题:我无法将所有 html.erb 转换为 haml。我用“rake haml:replace_erbs”命令尝试了 erb2haml gem,但它不起作用。这是完整的错误:

C:\xampp\htdocs\Ruby>rake haml:replace_erbs --trace
** Invoke haml:replace_erbs (first_time)
** Execute haml:replace_erbs
rake aborted!
Errno::ENOENT: No such file or directory - which html2haml
C:/Ruby193/lib/ruby/gems/1.9.1/gems/erb2haml-0.1.5/lib/erb2haml/railties/erb2haml.rake:46:in ``'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/erb2haml-0.1.5/lib/erb2haml/railties/erb2haml.rake:46:in `block (2 levels) i
n <top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
C:/Ruby193/bin/rake:23:in `load'
C:/Ruby193/bin/rake:23:in `<main>'
Tasks: TOP => haml:replace_erbs

似乎 gem 试图在我的 Windows 机器上使用“which”命令,这是没有意义的,因为它在 Windows 上不存在。有没有办法用 Windows“where”命令替换 linux/mac“which”命令?如果没有,是否有其他方法可以立即将所有 html.erb 替换为 haml's?

希望你能帮助我。谢谢。

-萌

我找到了一个非常简单的好方法。首先安装 "haml-rails" gem 如果你还没有,然后插入

rake haml:erb2haml

在控制台中。它将所有 .erb 视图转换为 .haml 。 工作非常快速和完美。

~干杯