dhl / erb2haml Goto Github PK
View Code? Open in Web Editor NEWSimple script to bulk covert ERB files in a Rails app to Haml
License: MIT License
Simple script to bulk covert ERB files in a Rails app to Haml
License: MIT License
I'm trying to use erb2haml to convert the ".rhtml" files in an old Rails application to HAML, but failed.
Below is the trace:
rake haml:convert_erbs --trace
'
(in C:/Users/chenfan/workspace/testRails)
** Invoke haml:convert_erbs (first_time)
** Execute haml:convert_erbs
rake aborted!
No such file or directory - which html2haml
C:/Ruby193/lib/ruby/gems/1.9.1/gems/erb2haml-0.1.2/lib/erb2haml/railties/erb2ham
l.rake:16:in ``'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/erb2haml-0.1.2/lib/erb2haml/railties/erb2ham
l.rake:16:inblock (2 levels) in <top (required)>' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in
call'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in`block
in execute'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in`execut
e'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158: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-0.9.2.2/lib/rake/task.rb:151:in `invoke
_with_call_chain'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in`invoke
'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in
`invoke_task'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in`
block (2 levels) in top_level'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `
each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in`
block in top_level'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in
`standard_exception_handling'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in`
top_level'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `
block in run'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in
`standard_exception_handling'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `
run'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in`<top (required)
'
C:/Ruby193/bin/rake:23:in `load'
C:/Ruby193/bin/rake:23:in `
Tasks: TOP => haml:convert_erbs
The javascript files should not be converted to haml
Hi David, I couldn't use the rake task you've built. The output:
$ rake haml:convert_erbs
(in /home/jose/rails/survay)
rake aborted!
Don't know how to build task 'haml:convert_erbs'
What should I do to make Rails recognize the task? Thanks.
Hi,
I think it would be nice to have a mode like this
$ rake haml:convert_erbs -- app/views/foo/bar.html.erb
You only give ERB paths you want to convert/replace.
Another mode where confirmation is required could be nice
$ rake haml:convert_erbs --confirm
Do you want to convert "foo/bar.html.erb" ? [Yn] Y
Do you want to convert "foo/baz.html.erb" ? [Yn] n
Here's a stack trace:
C:\projects\Index>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:inblock (2 levels) in <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`
The issue is that in line 46 of the erb2haml.rake file, it does this check:
if which html2haml
.empty?
'which' is a linux (and I assume Mac) command. I replaced the 'which' with the windows semi-equivalent 'where' and it worked ok.
Thought you'd like to know that this is an issue.
Hello.
I am Japanese user and when I run rake haml:convert_erbs
, following errors are returned against some erb files.
Error on line 128: Invalid Windows-31J character "\xE6"
(error character is different for each case, such as "\xE6" or "\xE4")
I compiled some erb templates and partials including Japanese characters. But somehow some of them causes error and the others not.
Moreover some says that put a code Encoding.default_external = 'utf-8'
to config.ru is efficient and the other says environmental variable LANG should be ja_JP.UTF-8
. I've tried both of them but cannot see any improvement.
Could you guess why?
Hi, is there a way to get the rake tasks to lookup the erb templates in Rails.root/lib/engine-name/app/views as well?
cheers, christian
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.