ie_conditional_tag 0.4.0
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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.md +117 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/lib/generators/ie_conditional_tag/install_generator.rb +19 -0
- data/lib/generators/templates/README +9 -0
- data/lib/generators/templates/ie_conditional_tag.rb +24 -0
- data/lib/ie_conditional_tag.rb +28 -0
- data/lib/ie_conditional_tag/condition.rb +28 -0
- data/lib/ie_conditional_tag/configuration.rb +20 -0
- data/lib/ie_conditional_tag/dsl.rb +63 -0
- data/lib/ie_conditional_tag/helper.rb +19 -0
- data/lib/ie_conditional_tag/protected_condition.rb +12 -0
- data/lib/ie_conditional_tag/railtie.rb +17 -0
- data/lib/ie_conditional_tag/unprotected_condition.rb +12 -0
- data/test/helper.rb +15 -0
- data/test/test_condition.rb +41 -0
- data/test/test_configuration.rb +17 -0
- data/test/test_tag_helper.rb +41 -0
- metadata +102 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Anthony Burns, Bruce Williams
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
IE Conditional Tag
|
2
|
+
==================
|
3
|
+
|
4
|
+
This Rails plugin provides an easy way to insert a tag multiple times
|
5
|
+
in an HTML document with IE conditional comments. This is an
|
6
|
+
alternate approach to conditional stylesheets and CSS hacks, and is
|
7
|
+
explained in detail by [Paul Irish][1].
|
8
|
+
|
9
|
+
You can learn more about conditional comments at [QuirksMode][2].
|
10
|
+
|
11
|
+
Example
|
12
|
+
-------
|
13
|
+
|
14
|
+
Shown generating the `html` tag (as [recommended][1]), and adding a
|
15
|
+
custom class:
|
16
|
+
|
17
|
+
<!DOCTYPE html>
|
18
|
+
<%= ie_conditional_tag :html, :class => 'some-custom-class' %>
|
19
|
+
<head>
|
20
|
+
<title>New HTML5 page</title>
|
21
|
+
</head>
|
22
|
+
<body>
|
23
|
+
<%= yield %>
|
24
|
+
</body>
|
25
|
+
</html>
|
26
|
+
|
27
|
+
This would give you (with some prettied indentation):
|
28
|
+
|
29
|
+
<!DOCTYPE html>
|
30
|
+
<!--[if lt IE 7]><html class="ie6 some-custom-class"><![endif]-->
|
31
|
+
<!--[if IE 7]><html class="ie7 some-custom-class"><![endif]-->
|
32
|
+
<!--[if IE 8]><html class="ie8 some-custom-class"><![endif]-->
|
33
|
+
<!--[if IE 9]><html class="ie9 some-custom-class"><![endif]-->
|
34
|
+
<!--[if gt IE 9]><html class="some-custom-class"><![endif]-->
|
35
|
+
<!--[if !IE]><!--><html class="some-custom-class"><!--<![endif]-->
|
36
|
+
<head>
|
37
|
+
<title>New HTML5 page</title>
|
38
|
+
</head>
|
39
|
+
<body>
|
40
|
+
<!-- your content -->
|
41
|
+
</body>
|
42
|
+
</html>
|
43
|
+
|
44
|
+
`ie_conditional_tag` will also accept a block, so this also works:
|
45
|
+
|
46
|
+
<!DOCTYPE html>
|
47
|
+
<%= ie_conditional_tag :html, :class => 'some-custom-class' do %>
|
48
|
+
<head>
|
49
|
+
<title>New HTML5 page</title>
|
50
|
+
</head>
|
51
|
+
<body>
|
52
|
+
<%= yield %>
|
53
|
+
</body>
|
54
|
+
<% end %>
|
55
|
+
|
56
|
+
Wait, that's an ugly name!
|
57
|
+
--------------------------
|
58
|
+
|
59
|
+
We aimed for descriptive and agnostic; you may want to add a helper to
|
60
|
+
call it, eg:
|
61
|
+
|
62
|
+
module ApplicationHelper
|
63
|
+
|
64
|
+
# ...
|
65
|
+
|
66
|
+
def html_tag(*args, &block)
|
67
|
+
ie_conditional_tag(*args, &block)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
Installation
|
73
|
+
------------
|
74
|
+
|
75
|
+
Use bundler. In your `Gemfile`:
|
76
|
+
|
77
|
+
gem 'ie_conditional_tag'
|
78
|
+
|
79
|
+
Install it:
|
80
|
+
|
81
|
+
$ bundler install
|
82
|
+
|
83
|
+
Then, run the following:
|
84
|
+
|
85
|
+
$ rails generate ie_conditional_tag:install
|
86
|
+
|
87
|
+
This will add the following initializer:
|
88
|
+
|
89
|
+
config/initializers/ie_conditional_tag.rb
|
90
|
+
|
91
|
+
You may want to look/tweak the settings there.
|
92
|
+
|
93
|
+
Note: By default, when IE 6, 7, 8, 9 are given the CSS classes 'ie6',
|
94
|
+
'ie7', 'ie8', and 'ie9' respectively. IE > 9 has no additional class
|
95
|
+
added (which may be overly optimistic). YMMV.
|
96
|
+
|
97
|
+
Configuring
|
98
|
+
-----------
|
99
|
+
|
100
|
+
For details on how to configure the plugin, see `lib/ie_conditional_tag/dsl.rb`.
|
101
|
+
|
102
|
+
Dependencies
|
103
|
+
------------
|
104
|
+
|
105
|
+
This plugin is only designed to work with Rails 3.0+.
|
106
|
+
|
107
|
+
Note: We're happy to accept pull requests that add backwards
|
108
|
+
compatibility with older versions of Rails.
|
109
|
+
|
110
|
+
Copyright
|
111
|
+
---------
|
112
|
+
|
113
|
+
Copyright (c) 2010 Anthony Burns, Bruce Williams. See LICENSE for
|
114
|
+
details.
|
115
|
+
|
116
|
+
[1]: http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
|
117
|
+
[2]: http://www.quirksmode.org/css/condcom.html
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "ie_conditional_tag"
|
8
|
+
gem.summary = %Q{IE conditional comments for Rails}
|
9
|
+
gem.description = %Q{Provides an easy-to-use helper for generating multiple tags inside IE-specific conditional comments}
|
10
|
+
gem.email = "bruce@codefluency.com"
|
11
|
+
gem.homepage = "http://github.com/bruce/ie_conditional_tag"
|
12
|
+
gem.authors = ["Anthony Burns", "Bruce Williams"]
|
13
|
+
gem.add_dependency 'rails', '~> 3.0'
|
14
|
+
end
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'rake/testtask'
|
21
|
+
Rake::TestTask.new(:test) do |test|
|
22
|
+
test.libs << 'lib' << 'test'
|
23
|
+
test.pattern = 'test/**/test_*.rb'
|
24
|
+
test.verbose = true
|
25
|
+
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
require 'rcov/rcovtask'
|
29
|
+
Rcov::RcovTask.new do |test|
|
30
|
+
test.libs << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
rescue LoadError
|
35
|
+
task :rcov do
|
36
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
task :test => :check_dependencies
|
41
|
+
|
42
|
+
task :default => :test
|
43
|
+
|
44
|
+
require 'rake/rdoctask'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
+
|
48
|
+
rdoc.rdoc_dir = 'rdoc'
|
49
|
+
rdoc.title = "ie_conditional_tag #{version}"
|
50
|
+
rdoc.rdoc_files.include('README*')
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.4.0
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module IeConditionalTag
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
source_root File.expand_path("../../templates", __FILE__)
|
6
|
+
|
7
|
+
desc "Creates a ie_conditional_tag initializer to configure your application."
|
8
|
+
|
9
|
+
def copy_initializer
|
10
|
+
template "ie_conditional_tag.rb", "config/initializers/ie_conditional_tag.rb"
|
11
|
+
end
|
12
|
+
|
13
|
+
def show_readme
|
14
|
+
readme "README" if behavior == :invoke
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
=============================================================
|
2
|
+
|
3
|
+
Added an initializer at:
|
4
|
+
|
5
|
+
config/initializers/ie_conditional_tag.rb
|
6
|
+
|
7
|
+
You can modify this file to change browser-specific settings.
|
8
|
+
|
9
|
+
=============================================================
|
@@ -0,0 +1,24 @@
|
|
1
|
+
IEConditionalTag.configure do |config|
|
2
|
+
|
3
|
+
# The standard `config.on` line looks like:
|
4
|
+
#
|
5
|
+
# on IE_CONDITIONAL_COMMENT_EXPRESSION, HTML_OPTIONS
|
6
|
+
#
|
7
|
+
# The `:class` option is special; unlike other attributes, its value
|
8
|
+
# will be prepended to any `:class` attribute given to `ie_conditional_tag`.
|
9
|
+
|
10
|
+
# Add CSS classes for IE 6 - 9
|
11
|
+
config.on 'lt IE 7', :class => 'ie6'
|
12
|
+
config.on 'IE 7', :class => 'ie7'
|
13
|
+
config.on 'IE 8', :class => 'ie8'
|
14
|
+
config.on 'IE 9', :class => 'ie9'
|
15
|
+
|
16
|
+
# For IE >= 9, no change
|
17
|
+
config.on 'gt IE 9'
|
18
|
+
|
19
|
+
# For all other browsers
|
20
|
+
# Note: Don't remove this line-- or other browsers won't get a
|
21
|
+
# visible tag!
|
22
|
+
config.on '!IE'
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'ie_conditional_tag/configuration'
|
2
|
+
require 'ie_conditional_tag/dsl'
|
3
|
+
require 'ie_conditional_tag/helper'
|
4
|
+
|
5
|
+
require 'ie_conditional_tag/condition'
|
6
|
+
require 'ie_conditional_tag/protected_condition'
|
7
|
+
require 'ie_conditional_tag/unprotected_condition'
|
8
|
+
|
9
|
+
require 'ie_conditional_tag/railtie'
|
10
|
+
|
11
|
+
module IEConditionalTag
|
12
|
+
|
13
|
+
def self.config
|
14
|
+
@config ||= Configuration.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.process(options = {}, &block)
|
18
|
+
config.inject('') do |result, condition|
|
19
|
+
result << condition.wrap(options.dup, &block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.configure(options = {}, &block)
|
24
|
+
@config = nil if options[:clear]
|
25
|
+
DSL.new(config, &block)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module IEConditionalTag
|
2
|
+
|
3
|
+
# Abstract
|
4
|
+
class Condition
|
5
|
+
|
6
|
+
def initialize(expression, options = {})
|
7
|
+
@expression = expression
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def merge_options(options = {})
|
14
|
+
css_class = options.delete(:class)
|
15
|
+
overridden = options.merge(@options)
|
16
|
+
if options[:class] || css_class
|
17
|
+
overridden.merge(:class => [@options[:class], css_class].compact.join(' '))
|
18
|
+
else
|
19
|
+
overridden
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module IEConditionalTag
|
2
|
+
|
3
|
+
class DSL
|
4
|
+
|
5
|
+
def initialize(config, &block)
|
6
|
+
@config = config
|
7
|
+
instance_eval(&block) if block
|
8
|
+
end
|
9
|
+
|
10
|
+
# Add a condition
|
11
|
+
#
|
12
|
+
# Unless +expression+ is "!IE", this will add a "protected"
|
13
|
+
# condition, meaning that the contents of the condition
|
14
|
+
# will be hidden inside a comment and will not be added to the DOM
|
15
|
+
# by other browsers.
|
16
|
+
#
|
17
|
+
# You can also use the more specific +add_protected_condition+ and
|
18
|
+
# +add_unprotected_condition+ directly.
|
19
|
+
#
|
20
|
+
# call-seq:
|
21
|
+
#
|
22
|
+
# on 'lt 7', :class => 'ie6'
|
23
|
+
# on '!IE' # for other browsers
|
24
|
+
#
|
25
|
+
def on(expression, options = {})
|
26
|
+
if expression.upcase == '!IE'
|
27
|
+
add_unprotected_condition(expression, options)
|
28
|
+
else
|
29
|
+
add_protected_condition(expression, options)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Add a protected condition.
|
34
|
+
#
|
35
|
+
# The contents of a protected condition will be hidden inside a
|
36
|
+
# comment and will not be added to the DOM by other browsers.
|
37
|
+
def add_protected_condition(expression, options = {})
|
38
|
+
add_condition(ProtectedCondition, expression, options)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Add an unprotected condition
|
42
|
+
#
|
43
|
+
# The contents of an unprotected condition will NOT be hidden from
|
44
|
+
# other browsers. There should only be one of these configured.
|
45
|
+
#
|
46
|
+
# This is commonly used for the modern/up-to-date/non-IE version,
|
47
|
+
# eg when +expression+ is "!IE" or "gt IE 9". Note you can add
|
48
|
+
# an unprotected condition using +on+ if you use the former
|
49
|
+
# expression (the latter may be too optimistic!)
|
50
|
+
def add_unprotected_condition(expression, options = {})
|
51
|
+
add_condition(UnprotectedCondition, expression, options)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def add_condition(klass, expression, options = {})
|
57
|
+
@config.conditions << klass.new(expression, options)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module IEConditionalTag
|
2
|
+
|
3
|
+
module Helper
|
4
|
+
|
5
|
+
def ie_conditional_tag(name, options = {}, &block)
|
6
|
+
result = IEConditionalTag.process(options) do |modified_options|
|
7
|
+
tag(name, modified_options, true)
|
8
|
+
end
|
9
|
+
result.chomp!
|
10
|
+
if block_given?
|
11
|
+
result << capture(&block)
|
12
|
+
result << raw("</#{name}>")
|
13
|
+
end
|
14
|
+
raw(result)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module IEConditionalTag
|
2
|
+
|
3
|
+
if defined?(Rails::Railtie)
|
4
|
+
require 'rails'
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
initializer 'ie_conditional_tag.insert_into_active_record' do
|
7
|
+
IEConditionalTag::Railtie.insert
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Railtie
|
13
|
+
def self.insert
|
14
|
+
ActionController::Base.helper(IEConditionalTag::Helper)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/core_ext'
|
5
|
+
require 'action_view'
|
6
|
+
require 'action_controller'
|
7
|
+
require 'action_controller/test_case'
|
8
|
+
|
9
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
10
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
11
|
+
|
12
|
+
require 'ie_conditional_tag'
|
13
|
+
Dir[File.expand_path('../../lib/ie_conditional_tag/*.rb', __FILE__)].each do |path|
|
14
|
+
require path
|
15
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestCondition < ActionView::TestCase
|
4
|
+
|
5
|
+
test "wrapping a tag in a protected condition without additional options" do
|
6
|
+
condition = IEConditionalTag::ProtectedCondition.new('IE 6', :class => 'ie6')
|
7
|
+
assert_equal(%Q(<!--[if IE 6]><body class="ie6"><![endif]-->\n),
|
8
|
+
condition.wrap { |opts| tag(:body, opts, true) })
|
9
|
+
end
|
10
|
+
|
11
|
+
test "wrapping a tag in an unprotected condition without additional options" do
|
12
|
+
condition = IEConditionalTag::UnprotectedCondition.new('!IE', :id => 'override', :class => 'non-ie')
|
13
|
+
result = condition.wrap(:id => 'custom', :class => 'basic') { |opts| tag(:body, opts, true) }
|
14
|
+
|
15
|
+
wrapper_pattern = Regexp.new(Regexp.quote('<!--[if !IE]><!--><body ') + '[^>]+' + Regexp.quote('><!--<![endif]-->'))
|
16
|
+
assert result =~ wrapper_pattern
|
17
|
+
assert result.include?('class="non-ie basic"')
|
18
|
+
assert result.include?('id="override"')
|
19
|
+
end
|
20
|
+
|
21
|
+
test "wrapping a tag in a protected condition with additional options" do
|
22
|
+
condition = IEConditionalTag::ProtectedCondition.new('IE 6', :id => 'override', :class => 'ie6')
|
23
|
+
result = condition.wrap(:id => 'custom', :class => 'basic') { |opts| tag(:body, opts, true) }
|
24
|
+
|
25
|
+
wrapper_pattern = Regexp.new(Regexp.quote('<!--[if IE 6]><body ') + '[^>]+' + Regexp.quote('><![endif]-->'))
|
26
|
+
assert result =~ wrapper_pattern
|
27
|
+
assert result.include?('class="ie6 basic"')
|
28
|
+
assert result.include?('id="override"')
|
29
|
+
end
|
30
|
+
|
31
|
+
test "wrapping a tag in an unprotected condition with additional options" do
|
32
|
+
condition = IEConditionalTag::UnprotectedCondition.new('!IE', :id => 'override', :class => 'no-ie')
|
33
|
+
result = condition.wrap(:id => 'custom', :class => 'basic') { |opts| tag(:body, opts, true) }
|
34
|
+
|
35
|
+
wrapper_pattern = Regexp.new(Regexp.quote('<!--[if !IE]><!--><body ') + '[^>]+' + Regexp.quote('><!--<![endif]-->'))
|
36
|
+
assert result =~ wrapper_pattern
|
37
|
+
assert result.include?('class="no-ie basic"')
|
38
|
+
assert result.include?('id="override"')
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestConfiguration < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
IEConditionalTag.config.clear
|
7
|
+
end
|
8
|
+
|
9
|
+
test "adding a condition" do
|
10
|
+
assert_equal 0, IEConditionalTag.config.conditions.size
|
11
|
+
IEConditionalTag.configure do |config|
|
12
|
+
config.on '!IE', :class => 'not-ie'
|
13
|
+
end
|
14
|
+
assert_equal 1, IEConditionalTag.config.conditions.size
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'action_view/template/handlers/erb'
|
3
|
+
|
4
|
+
class TestIEConditionalTag < ActionView::TestCase
|
5
|
+
tests IEConditionalTag::Helper
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@response = ActionController::TestResponse.new
|
9
|
+
IEConditionalTag.config.clear
|
10
|
+
IEConditionalTag.configure do |config|
|
11
|
+
config.on 'lt IE 7', :class => 'ie6'
|
12
|
+
config.on 'IE 7', :class => 'ie7'
|
13
|
+
config.on 'IE 8', :class => 'ie8'
|
14
|
+
config.on 'IE 9', :class => 'ie9'
|
15
|
+
config.on 'gt IE 9'
|
16
|
+
config.on '!IE'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
test "browser body tag with no options and no block" do
|
21
|
+
rendered = String.new(ie_conditional_tag(:html))
|
22
|
+
assert rendered.include?('<!--[if lt IE 7]><html class="ie6"><![endif]-->'), rendered
|
23
|
+
assert rendered.include?('<!--[if IE 7]><html class="ie7"><![endif]-->'), rendered
|
24
|
+
assert rendered.include?('<!--[if IE 8]><html class="ie8"><![endif]-->'), rendered
|
25
|
+
assert rendered.include?('<!--[if IE 9]><html class="ie9"><![endif]-->'), rendered
|
26
|
+
assert rendered.include?('<!--[if gt IE 9]><html><![endif]-->'), rendered
|
27
|
+
assert rendered.include?('<!--[if !IE]><!--><html><!--<![endif]-->'), rendered
|
28
|
+
end
|
29
|
+
|
30
|
+
test "browser body tag with class option and no block" do
|
31
|
+
rendered = String.new(ie_conditional_tag(:html, :class => 'custom-class'))
|
32
|
+
assert rendered.include?('<!--[if lt IE 7]><html class="ie6 custom-class"><![endif]-->'), rendered
|
33
|
+
assert rendered.include?('<!--[if IE 7]><html class="ie7 custom-class"><![endif]-->'), rendered
|
34
|
+
assert rendered.include?('<!--[if IE 8]><html class="ie8 custom-class"><![endif]-->'), rendered
|
35
|
+
assert rendered.include?('<!--[if IE 9]><html class="ie9 custom-class"><![endif]-->'), rendered
|
36
|
+
assert rendered.include?('<!--[if gt IE 9]><html class="custom-class"><![endif]-->'), rendered
|
37
|
+
assert rendered.include?('<!--[if !IE]><!--><html class="custom-class"><!--<![endif]-->'), rendered
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ie_conditional_tag
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
version: 0.4.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Anthony Burns
|
13
|
+
- Bruce Williams
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-09 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rails
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 3
|
31
|
+
- 0
|
32
|
+
version: "3.0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Provides an easy-to-use helper for generating multiple tags inside IE-specific conditional comments
|
36
|
+
email: bruce@codefluency.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.md
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- lib/generators/ie_conditional_tag/install_generator.rb
|
52
|
+
- lib/generators/templates/README
|
53
|
+
- lib/generators/templates/ie_conditional_tag.rb
|
54
|
+
- lib/ie_conditional_tag.rb
|
55
|
+
- lib/ie_conditional_tag/condition.rb
|
56
|
+
- lib/ie_conditional_tag/configuration.rb
|
57
|
+
- lib/ie_conditional_tag/dsl.rb
|
58
|
+
- lib/ie_conditional_tag/helper.rb
|
59
|
+
- lib/ie_conditional_tag/protected_condition.rb
|
60
|
+
- lib/ie_conditional_tag/railtie.rb
|
61
|
+
- lib/ie_conditional_tag/unprotected_condition.rb
|
62
|
+
- test/helper.rb
|
63
|
+
- test/test_condition.rb
|
64
|
+
- test/test_configuration.rb
|
65
|
+
- test/test_tag_helper.rb
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: http://github.com/bruce/ie_conditional_tag
|
68
|
+
licenses: []
|
69
|
+
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options:
|
72
|
+
- --charset=UTF-8
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 1.3.7
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: IE conditional comments for Rails
|
98
|
+
test_files:
|
99
|
+
- test/helper.rb
|
100
|
+
- test/test_condition.rb
|
101
|
+
- test/test_configuration.rb
|
102
|
+
- test/test_tag_helper.rb
|