File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
lib/rails/generators/haml/application_layout Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 1
1
require 'rails'
2
+ require 'shellwords'
2
3
3
4
module Haml
4
5
module Generators
5
6
class ApplicationLayoutGenerator < ::Rails ::Generators ::Base
6
7
8
+ HTML_LAYOUT_PATH = 'app/views/layouts/application.html.erb'
9
+ HAML_LAYOUT_PATH = 'app/views/layouts/application.html.haml'
10
+
7
11
# Converts existing application.html.erb to haml format,
8
12
# and creates app/views/layouts/application.html.haml
9
13
# with some error checking.
10
14
def convert
11
- app_layout_from = ::Rails . root . join ( 'app/views/layouts/application.html.erb' )
12
- app_layout_to = ::Rails . root . join ( 'app/views/layouts/application.html.haml' )
15
+ app_layout_from = ::Rails . root . join ( HTML_LAYOUT_PATH ) . to_s
16
+ app_layout_to = ::Rails . root . join ( HAML_LAYOUT_PATH ) . to_s
13
17
14
18
if File . exist? ( app_layout_from )
15
19
16
20
if !File . exist? ( app_layout_to )
17
- `html2haml #{ app_layout_from } #{ app_layout_to } `
21
+ `html2haml #{ app_layout_from . shellescape } #{ app_layout_to . shellescape } `
18
22
puts "Success! app/views/layouts/application.html.haml is created.\n " \
19
23
"Please remove the erb file: app/views/layouts/application.html.erb"
20
24
else
You can’t perform that action at this time.
0 commit comments