seivan-generators 0.2 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,10 @@ Feature: Seivan HTML5 Generator with HAML
14
14
  And I should see "= render :partial => 'layouts/flashes'" in file "app/views/layouts/application.html.haml"
15
15
  And I should see "= render :partial => 'layouts/footer'" in file "app/views/layouts/application.html.haml"
16
16
  And I should see "= render :partial => 'layouts/javascripts'" in file "app/views/layouts/application.html.haml"
17
+
18
+ Scenario: Generate layout helper and include it in application controller
19
+ Then I should see file "app/helpers/layout_helper.rb"
20
+ And I should see "helper :layout" in file "app/controllers/application_controller.rb"
17
21
 
18
22
  Scenario: Generate head partial with rendering stylesheets with a yield :stylesheets
19
23
  Then I should see file "app/views/layouts/_head.html.haml"
@@ -19,6 +19,8 @@ module Seivan
19
19
  template "_errors.html.haml", "app/views/shared/_errors.html.haml"
20
20
  template "jquery.js", "public/javascripts/jquery.js"
21
21
  template "jquery_ujs.js", "public/javascripts/jquery_ujs.js"
22
+ template "layout_helper.rb", "app/helpers/layout_helper.rb"
23
+ inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " helper :layout\n"
22
24
  end
23
25
  end
24
26
 
@@ -0,0 +1,34 @@
1
+ module LayoutHelper
2
+ def ie_tag(name=:body, attrs={}, &block)
3
+ attrs.symbolize_keys!
4
+ haml_concat("<!--[if lt IE 7 ]> #{ tag(name, add_class('ie6', attrs), true) } <![endif]-->".html_safe)
5
+ haml_concat("<!--[if IE 7 ]> #{ tag(name, add_class('ie7', attrs), true) } <![endif]-->".html_safe)
6
+ haml_concat("<!--[if IE 8 ]> #{ tag(name, add_class('ie8', attrs), true) } <![endif]-->".html_safe)
7
+ haml_concat("<!--[if IE 9 ]> #{ tag(name, add_class('ie9', attrs), true) } <![endif]-->".html_safe)
8
+ haml_concat("<!--[if (gt IE 9)|!(IE)]><!-->".html_safe)
9
+ haml_tag name, attrs do
10
+ haml_concat("<!--<![endif]-->".html_safe)
11
+ block.call
12
+ end
13
+ end
14
+
15
+ def ie_html(attrs={}, &block)
16
+ ie_tag(:html, attrs, &block)
17
+ end
18
+
19
+ def ie_body(attrs={}, &block)
20
+ ie_tag(:body, attrs, &block)
21
+ end
22
+
23
+
24
+ private
25
+
26
+ def add_class(name, attrs)
27
+ classes = attrs[:class] || ''
28
+ classes.strip!
29
+ classes = ' ' + classes if !classes.blank?
30
+ classes = name + classes
31
+ attrs.merge(:class => classes)
32
+ end
33
+
34
+ end
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- version: "0.2"
7
+ - 3
8
+ version: "0.3"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Seivan Heidari
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2010-10-27 00:00:00 +02:00
16
+ date: 2010-10-28 00:00:00 +02:00
17
17
  default_executable:
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
@@ -143,6 +143,7 @@ files:
143
143
  - lib/generators/seivan/html5/templates/application.html.haml
144
144
  - lib/generators/seivan/html5/templates/jquery.js
145
145
  - lib/generators/seivan/html5/templates/jquery_ujs.js
146
+ - lib/generators/seivan/html5/templates/layout_helper.rb
146
147
  - lib/generators/seivan/html5/USAGE
147
148
  - lib/generators/seivan.rb
148
149
  - test/test_helper.rb