Sha256: fa0a5acde78e5991385d176d60ca677bdd553dc52a884ae82124b860ae02da8d

Contents?: true

Size: 1.73 KB

Versions: 15

Compression:

Stored size: 1.73 KB

Contents

# Application template recipe for the rails_apps_composer. Check for a newer version here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/application_layout.rb

after_bundler do

  say_wizard "ApplicationLayout recipe running 'after bundler'"

  # Set up the default application layout
  if recipes.include? 'haml'
    remove_file 'app/views/layouts/application.html.erb'
    remove_file 'app/views/layouts/application.html.haml'
    # There is Haml code in this script. Changing the indentation is perilous between HAMLs.
    create_file 'app/views/layouts/application.html.haml' do <<-HAML
!!! 5
%html
  %head
    %title #{app_name}
    = stylesheet_link_tag :application
    = javascript_include_tag :application
    = csrf_meta_tags
  %body
    - flash.each do |name, msg|
      = content_tag :div, msg, :id => "flash_\#{name}" if msg.is_a?(String)
    = yield
HAML
    end
    if recipes.include? 'rails 3.0'
      gsub_file 'app/views/layouts/application.html.haml', /stylesheet_link_tag :application/, 'stylesheet_link_tag :all'
      gsub_file 'app/views/layouts/application.html.haml', /javascript_include_tag :application/, 'javascript_include_tag :defaults'
      gsub_file 'app/views/layouts/application.html.haml', /csrf_meta_tags/, 'csrf_meta_tag'
    end
  else
    unless recipes.include? 'html5'
      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
  end

end

__END__

name: ApplicationLayout
description: "Add a default application layout with flash messages."
author: RailsApps

category: other
tags: [utilities, configuration]

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rails_apps_composer-1.0.26 recipes/application_layout.rb
rails_apps_composer-1.0.25 recipes/application_layout.rb
rails_apps_composer-1.0.24 recipes/application_layout.rb
rails_apps_composer-1.0.23 recipes/application_layout.rb
rails_apps_composer-1.0.22 recipes/application_layout.rb
rails_apps_composer-1.0.21 recipes/application_layout.rb
rails_apps_composer-1.0.20 recipes/application_layout.rb
rails_apps_composer-1.0.19 recipes/application_layout.rb
rails_apps_composer-1.0.18 recipes/application_layout.rb
rails_apps_composer-1.0.17 recipes/application_layout.rb
rails_apps_composer-1.0.16 recipes/application_layout.rb
rails_apps_composer-1.0.15 recipes/application_layout.rb
rails_apps_composer-1.0.14 recipes/application_layout.rb
rails_apps_composer-1.0.12 recipes/application_layout.rb
rails_apps_composer-1.0.11 recipes/application_layout.rb