Skip to content

Commit

Permalink
Add haml support
Browse files Browse the repository at this point in the history
  • Loading branch information
ruprict committed Nov 11, 2011
1 parent 0376ec4 commit 6f44324
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 23 deletions.
10 changes: 8 additions & 2 deletions 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?
Expand Down
43 changes: 22 additions & 21 deletions lib/generators/skeleton_layout/templates/index.html
@@ -1,23 +1,24 @@
<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
<head>

<!-- Basic Page Needs
================================================== -->
<meta charset="utf-8">
<title>Your Page Title Here :)</title>
<meta name="description" content="">
<meta name="author" content="">
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<!-- Mobile Specific Metas
================================================== -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
!!!
/[if lt IE 7 ] <html class="ie ie6" lang="en">
/[if IE 7 ] <html class="ie ie7" lang="en">
/[if IE 8 ] <html class="ie ie8" lang="en">
/[if (gte IE 9)|!(IE)] <html lang="en">
%head
%meta{:charset => "utf-8"}
%title Your Page Title Here :)
%meta{:name => "description", :content => ""}
%meta{:name => "author", :content =>""}
/[if lt IE 9]
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
/
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"}

<!-- CSS
================================================== -->
Expand Down Expand Up @@ -78,4 +79,4 @@ <h3>Docs &amp; Support</h3>
<!-- End Document
================================================== -->
</body>
</html>
</html>
61 changes: 61 additions & 0 deletions lib/generators/skeleton_layout/templates/index.html.haml
@@ -0,0 +1,61 @@
!!!
/[if lt IE 7 ] <html class="ie ie6" lang="en">
/[if IE 7 ] <html class="ie ie7" lang="en">
/[if IE 8 ] <html class="ie ie8" lang="en">
/[if (gte IE 9)|!(IE)] <html lang="en">
%head
%meta{:charset => "utf-8"}
%title Your Page Title Here :)
%meta{ :name => "description", :content => ""}
%meta{ :name => "author", :content => ""}
/[if lt IE 9]
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>

%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 &amp; 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 &amp; Support
%p The easiest way to really get started with Skeleton is to check out the full docs and info at <a href="http://www.getskeleton.com">www.getskeleton.com.</a>. Skeleton is also open-source and has a <a href="https://github.com/dhgamache/skeleton">project on git</a>, 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 <a href="mailto:hi@getskeleton.com">hi@getskeleton.com</a>.
/ JS
/ ==================================================
%script{ :src => "//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"}
%script{ :src => "javascripts/tabs.js"}
6 changes: 6 additions & 0 deletions test/skeleton_layout_generator_test.rb
Expand Up @@ -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

0 comments on commit 6f44324

Please sign in to comment.