File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
lib/rails/generators/haml/application_layout Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 5
5
6
6
gem 'rubysl' , '~> 2.0' , platforms : :rbx
7
7
gem 'minitest' , platforms : :rbx
8
+ gem 'html2haml'
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
s . add_dependency "activesupport" , [ ">= 4.0.1" ]
20
20
s . add_dependency "actionpack" , [ ">= 4.0.1" ]
21
21
s . add_dependency "railties" , [ ">= 4.0.1" ]
22
+ s . add_dependency "html2haml" , [ ">= 1.0.1" ]
22
23
23
24
s . add_development_dependency "rails" , [ ">= 4.0.1" ]
24
25
s . add_development_dependency "bundler" , "~> 1.2"
Original file line number Diff line number Diff line change
1
+ require 'rails'
2
+
3
+ module Haml
4
+ module Generators
5
+ class ApplicationLayoutGenerator < ::Rails ::Generators ::Base
6
+
7
+ # Converts existing application.html.erb to haml format,
8
+ # and creates app/views/layouts/application.html.haml
9
+ # with some error checking.
10
+ 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' )
13
+
14
+ if File . exist? ( app_layout_from )
15
+
16
+ if !File . exist? ( app_layout_to )
17
+ `html2haml #{ app_layout_from } #{ app_layout_to } `
18
+ puts "Success! app/views/layouts/application.html.haml is created.\n " \
19
+ "Please remove the erb file: app/views/layouts/application.html.erb"
20
+ else
21
+ puts "Error! There is a file named app/views/layouts/application.html.haml already."
22
+ end
23
+ else
24
+ puts "Error! There is no file named app/views/layouts/application.html.erb."
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
31
+ end
You can’t perform that action at this time.
0 commit comments