From 6f44324fbe4677ba095d8286e41d2d51a00e1f08 Mon Sep 17 00:00:00 2001 From: Glenn Goodrich Date: Fri, 11 Nov 2011 11:27:23 -0500 Subject: [PATCH] Add haml support --- .../skeleton_layout_generator.rb | 10 ++- .../skeleton_layout/templates/index.html | 43 ++++++------- .../skeleton_layout/templates/index.html.haml | 61 +++++++++++++++++++ test/skeleton_layout_generator_test.rb | 6 ++ 4 files changed, 97 insertions(+), 23 deletions(-) create mode 100644 lib/generators/skeleton_layout/templates/index.html.haml diff --git a/lib/generators/skeleton_layout/skeleton_layout_generator.rb b/lib/generators/skeleton_layout/skeleton_layout_generator.rb index 5f432b3..8f0d2bd 100644 --- a/lib/generators/skeleton_layout/skeleton_layout_generator.rb +++ b/lib/generators/skeleton_layout/skeleton_layout_generator.rb @@ -1,16 +1,22 @@ class SkeletonLayoutGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) argument :layout_name, :type => :string, :default => 'application' + class_option :haml, :desc => "Generate HAML for layout view", :type => :boolean # TODO: Option for haml? - + + # Copies the Skeleton files to their respecitve locations def create_layout style_path = 'public' if (Rails.version =~ /^3\.1/) != nil # For Rails 3.1 and its assets pipeline we don't want to overwrite application.css style_path = 'app/assets' end - template "index.html.erb", "app/views/layouts/#{file_name}.html.erb" + if options.haml? + template "index.html.haml", "app/views/layouts/#{file_name}.html.haml" + else + template "index.html.erb", "app/views/layouts/#{file_name}.html.erb" + end copy_file '404.html', 'public/404.html' copy_file 'robots.txt', 'public/robots.txt' # Do these need to go in vendor/assets? diff --git a/lib/generators/skeleton_layout/templates/index.html b/lib/generators/skeleton_layout/templates/index.html index 9f9d7d0..464e25a 100644 --- a/lib/generators/skeleton_layout/templates/index.html +++ b/lib/generators/skeleton_layout/templates/index.html @@ -1,23 +1,24 @@ - - - - - - - - - - Your Page Title Here :) - - - - - - +!!! +/[if lt IE 7 ] +/[if IE 7 ] +/[if IE 8 ] +/[if (gte IE 9)|!(IE)] +%head + %meta{:charset => "utf-8"} + %title Your Page Title Here :) + %meta{:name => "description", :content => ""} + %meta{:name => "author", :content =>""} + /[if lt IE 9] + + / + Favicons + \================================================== + %link{:href => "images/favicon.ico", :rel => "shortcut icon"} + %link{:href => "images/apple-touch-icon.png", :rel => "apple-touch-icon"} + %link{:href => "images/apple-touch-icon-72x72.png", :rel => "apple-touch-icon", :sizes => "72x72"} + %link{:href => "images/apple-touch-icon-114x114.png", :rel => "apple-touch-icon", :sizes => "114x114"} + + %meta{ :name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"} @@ -78,4 +79,4 @@

Docs & Support

- \ No newline at end of file + diff --git a/lib/generators/skeleton_layout/templates/index.html.haml b/lib/generators/skeleton_layout/templates/index.html.haml new file mode 100644 index 0000000..9cd7f2c --- /dev/null +++ b/lib/generators/skeleton_layout/templates/index.html.haml @@ -0,0 +1,61 @@ +!!! +/[if lt IE 7 ] +/[if IE 7 ] +/[if IE 8 ] +/[if (gte IE 9)|!(IE)] +%head + %meta{:charset => "utf-8"} + %title Your Page Title Here :) + %meta{ :name => "description", :content => ""} + %meta{ :name => "author", :content => ""} + /[if lt IE 9] + + + %meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"} + + / + / Favicons + /================================================== + %link{:href => "images/favicon.ico", :rel => "shortcut icon"} + %link{:href => "images/apple-touch-icon.png", :rel => "apple-touch-icon"} + %link{:href => "images/apple-touch-icon-72x72.png", :rel => "apple-touch-icon", :sizes => "72x72"} + %link{:href => "images/apple-touch-icon-114x114.png", :rel => "apple-touch-icon", :sizes => "114x114"} + = stylesheet_link_tag "<%= file_name %>" + = javascript_include_tag "<%= file_name %>" + = csrf_meta_tag +%body + / Primary Page Layout + / Delete everything in this .container and get started on your own site! + %div.container + %div.sixteen.columns + %h1.remove-bottom{:style => "margin-top: 40px"} Skeleton + %h5 Version 1.1 + %hr + %div.sixteen.columns + = yield + %div.one-third.column + %h3 About Skeleton? + %p Skeleton is a small collection of well-organized CSS & JS files that can help you rapidly develop sites that look beautiful at any size, be it a 17" laptop screen or an iPhone. It's based on a responsive grid, but also provides very basic CSS for typography, buttons, tabs, forms and media queries. Go ahead, resize this super basic page to see the grid in action. + + %div.one-third.column + %h3 Three Core Principles + %p Skeleton is built on three core principles: + %ul.square + %li + %strong A Responsive Grid Down To Mobile + %span : Elegant scaling from a browser to tablets to mobile. + %li + %strong Fast to Start + %span :It's a tool for rapid development with best practices. + %li + %strong Style Agnostic + %span : It provides the most basic, beautiful styles, but is meant to be overwritten. + %div.one-third.column + %h3 Docs & Support + %p The easiest way to really get started with Skeleton is to check out the full docs and info at www.getskeleton.com.. Skeleton is also open-source and has a project on git, so check that out if you want to report bugs or create a pull request. If you have any questions, thoughts, concerns or feedback, please don't hesitate to email me at hi@getskeleton.com. + + / JS + / ================================================== + %script{ :src => "//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"} + %script{ :src => "javascripts/tabs.js"} + diff --git a/test/skeleton_layout_generator_test.rb b/test/skeleton_layout_generator_test.rb index d732adc..dd34d3c 100644 --- a/test/skeleton_layout_generator_test.rb +++ b/test/skeleton_layout_generator_test.rb @@ -35,5 +35,11 @@ def test_standard_assets_no_asset_pipeline assert_file "public/stylesheets/layout.css" assert_file "public/stylesheets/skeleton.css" end + + def test_standard_assets_with_haml + run_generator %w{--haml} + assert_file "app/views/layouts/application.html.haml" + + end end