Class: IEConditionalTag::DSL
- Inherits:
-
Object
- Object
- IEConditionalTag::DSL
- Defined in:
- lib/ie_conditional_tag/dsl.rb
Instance Method Summary collapse
-
#add_protected_condition(expression, options = {}) ⇒ Object
Add a protected condition.
-
#add_unprotected_condition(expression, options = {}) ⇒ Object
Add an unprotected condition.
-
#initialize(config, &block) ⇒ DSL
constructor
A new instance of DSL.
-
#on(expression, options = {}) ⇒ Object
Add a condition.
Constructor Details
#initialize(config, &block) ⇒ DSL
Returns a new instance of DSL.
5 6 7 8 |
# File 'lib/ie_conditional_tag/dsl.rb', line 5 def initialize(config, &block) @config = config instance_eval(&block) if block end |
Instance Method Details
#add_protected_condition(expression, options = {}) ⇒ Object
Add a protected condition.
The contents of a protected condition will be hidden inside a comment and will not be added to the DOM by other browsers.
37 38 39 |
# File 'lib/ie_conditional_tag/dsl.rb', line 37 def add_protected_condition(expression, = {}) add_condition(ProtectedCondition, expression, ) end |
#add_unprotected_condition(expression, options = {}) ⇒ Object
Add an unprotected condition
The contents of an unprotected condition will NOT be hidden from other browsers. There should only be one of these configured.
This is commonly used for the modern/up-to-date/non-IE version, eg when expression
is “!IE” or “gt IE 9”. Note you can add an unprotected condition using on
if you use the former expression (the latter may be too optimistic!)
50 51 52 |
# File 'lib/ie_conditional_tag/dsl.rb', line 50 def add_unprotected_condition(expression, = {}) add_condition(UnprotectedCondition, expression, ) end |
#on(expression, options = {}) ⇒ Object
Add a condition
Unless expression
is “!IE”, this will add a “protected” condition, meaning that the contents of the condition will be hidden inside a comment and will not be added to the DOM by other browsers.
You can also use the more specific add_protected_condition
and add_unprotected_condition
directly.
call-seq:
on 'lt 7', :class => 'ie6'
on '!IE' # for other browsers
25 26 27 28 29 30 31 |
# File 'lib/ie_conditional_tag/dsl.rb', line 25 def on(expression, = {}) if expression.upcase == '!IE' add_unprotected_condition(expression, ) else add_protected_condition(expression, ) end end |