From ebff69d78f8adb87cedd82464997f2744330542d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zg=C3=BCr=20=C3=96ZKAN?= Date: Thu, 9 May 2013 07:42:31 +0300 Subject: [PATCH] issue #26 replace files erb to haml --- lib/cybele/app_builder.rb | 5 +++++ lib/cybele/generators/app_generator.rb | 17 ++++++++++++----- templates/Gemfile_new | 2 ++ .../app/views/layouts/application.html.haml.erb | 9 +++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 templates/app/views/layouts/application.html.haml.erb diff --git a/lib/cybele/app_builder.rb b/lib/cybele/app_builder.rb index 0b48a04..f47a3aa 100644 --- a/lib/cybele/app_builder.rb +++ b/lib/cybele/app_builder.rb @@ -26,5 +26,10 @@ def replace_gemfile copy_file 'Gemfile_new', 'Gemfile' end + # Internal: Replace erb files with html files + def replace_erb_with_haml + remove_file 'app/views/layouts/application.html.erb' + template 'app/views/layouts/application.html.haml.erb', 'app/views/layouts/application.html.haml', :force => true + end end end \ No newline at end of file diff --git a/lib/cybele/generators/app_generator.rb b/lib/cybele/generators/app_generator.rb index 058d245..c511668 100644 --- a/lib/cybele/generators/app_generator.rb +++ b/lib/cybele/generators/app_generator.rb @@ -19,13 +19,20 @@ class AppGenerator < Rails::Generators::AppGenerator # Internal: Finish template def finish_template invoke :customization - invoke :customize_gemfile super end # Internal: Customization template def customization + invoke :customize_gemfile invoke :remove_files_we_dont_need + invoke :replace_files + end + + # Internal: Customize gemfile + def customize_gemfile + build :replace_gemfile + bundle_command 'install --binstubs=bin/stubs' end # Internal: Remove files don't need @@ -35,10 +42,10 @@ def remove_files_we_dont_need build :remove_readme_rdoc end - # Internal: Customize gemfile - def customize_gemfile - build :replace_gemfile - bundle_command 'install --binstubs=bin/stubs' + # Internal: Replace files + def replace_files + say 'Replace files' + build :replace_erb_with_haml end # Internal: Let's not: We'll bundle manually at the right spot. diff --git a/templates/Gemfile_new b/templates/Gemfile_new index 3dc6f7e..c99507c 100644 --- a/templates/Gemfile_new +++ b/templates/Gemfile_new @@ -7,6 +7,8 @@ gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.0.0' gem 'jquery-rails' gem 'turbolinks' +gem "haml", "~> 4.0.2" +gem "haml-rails", "~> 0.4" group :doc do gem 'sdoc', require: false diff --git a/templates/app/views/layouts/application.html.haml.erb b/templates/app/views/layouts/application.html.haml.erb new file mode 100644 index 0000000..a04f0bd --- /dev/null +++ b/templates/app/views/layouts/application.html.haml.erb @@ -0,0 +1,9 @@ +!!! +%html + %head + %title <%= app_name %> + = stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true + = javascript_include_tag "application", "data-turbolinks-track" => true + = csrf_meta_tags + %body + = yield \ No newline at end of file