-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapplication_layout.rb
47 lines (40 loc) · 1.38 KB
/
application_layout.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# >--------------------------------[ application_layout ]--------------------------------<
# Application template recipe. Check for a newer version here:
# https://github.com/fortuity/rails-template-recipes/blob/master/application_layout.rb
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
say_recipe 'Application Layout'
after_bundler do
#----------------------------------------------------------------------------
# Set up the default application layout
#----------------------------------------------------------------------------
if recipe_list.include? 'haml'
remove_file 'app/views/layouts/application.html.erb'
create_file 'app/views/layouts/application.html.haml' do <<-HAML
!!!
%html
%head
%title #{app_name}
= stylesheet_link_tag :all
= javascript_include_tag :defaults
= csrf_meta_tag
%body
- flash.each do |name, msg|
= content_tag :div, msg, :id => "flash_\#{name}" if msg.is_a?(String)
= yield
HAML
end
else
inject_into_file 'app/views/layouts/application.html.erb', :after => "<body>\n" do
<<-ERB
<%- flash.each do |name, msg| -%>
<%= content_tag :div, msg, :id => "flash_\#{name}" if msg.is_a?(String) %>
<%- end -%>
ERB
end
end
if extra_recipes.include? 'git'
git :tag => "app_layout"
git :add => '.'
git :commit => "-am 'Add application layout.'"
end
end