Module: WrapIt::HTML
Overview
Methods for manipulationg with HTML class. For internal usage.
You should not include this class directly - subclass from
WrapIt::Base instead.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
#html_class([html_class, ...]) ⇒ void
extended
from ClassMethods
Adds default html classes, thats are automatically added when element created.
-
.html_class_prefix(prefix = nil) ⇒ void
extended
from ClassMethods
Sets HTML class prefix.
Instance Method Summary collapse
-
#html_attr ⇒ Hash
Retrieves HTML attributes hash (without HTML class and HTML data).
-
#html_attr=(hash) ⇒ Hash
TODO: actually we should have separate setter and merge (see Base).
-
#html_class ⇒ HTMLClass
Retrieves HTML class of element.
-
#html_class=(value) ⇒ HTMLClass
Sets HTML class(es) for element.
-
#html_class_prefix ⇒ String
HTML class prefix getter.
-
#html_data ⇒ Hash
Retrieves HTML data hash.
Class Method Details
#html_class([html_class, ...]) ⇒ void Originally defined in module ClassMethods
This method returns an undefined value.
Adds default html classes, thats are automatically added when element created.
.html_class_prefix(prefix = nil) ⇒ void Originally defined in module ClassMethods
This method returns an undefined value.
Sets HTML class prefix. It used in switchers and enums
Instance Method Details
#html_attr ⇒ Hash
Retrieves HTML attributes hash (without HTML class and HTML data)
64 65 66 |
# File 'lib/wrap_it/html.rb', line 64 def html_attr @html_attr ||= {} end |
#html_attr=(hash) ⇒ Hash
TODO: actually we should have separate setter and merge (see Base)
Sets HTML attributes hash.
Actually it merges its with current
attributes. To remove some attributes use html_attr.delete(:attr).
extracts HTML class and data from provided hash and places its to
appropriate holder
52 53 54 55 56 57 58 |
# File 'lib/wrap_it/html.rb', line 52 def html_attr=(hash) return unless hash.is_a?(Hash) hash.symbolize_keys! html_class << hash.delete(:class) html_data.merge(hash.delete(:data) || {}) (@html_attr ||= {}).merge!(hash) end |
#html_class ⇒ HTMLClass
Retrieves HTML class of element
See WrapIt::HTMLClass for details
107 108 109 |
# File 'lib/wrap_it/html.rb', line 107 def html_class @html_class ||= HTMLClass.new end |
#html_class=(value) ⇒ HTMLClass
Sets HTML class(es) for element
97 98 99 |
# File 'lib/wrap_it/html.rb', line 97 def html_class=(value) @html_class = HTMLClass.new(value) end |
#html_class_prefix ⇒ String
HTML class prefix getter
This prefix used in enums to combine HTML classes.
82 83 84 |
# File 'lib/wrap_it/html.rb', line 82 def html_class_prefix @html_class_prefix ||= self.class.html_class_prefix end |
#html_data ⇒ Hash
Retrieves HTML data hash
72 73 74 |
# File 'lib/wrap_it/html.rb', line 72 def html_data @html_data ||= {} end |