【问题标题】:Can't convert html.erb's to haml with the "erb2haml" gem on Windows无法在 Windows 上使用“erb2haml”gem 将 html.erb 转换为 haml
【发布时间】:2015-06-10 10:40:14
【问题描述】:

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

我的问题:我无法将所有 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.erbs 替换为 haml 的?

我希望你能帮助我。谢谢。

-萌

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-4 rubygems haml


    【解决方案1】:

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

    rake haml:erb2haml
    

    在控制台中。它将所有 .erb 视图转换为 .haml 。 运行速度非常快,完美无瑕。

    ~干杯

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-10
      • 2011-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多