Class: Input::Tag
- Inherits:
-
Object
- Object
- Input::Tag
- Defined in:
- lib/input.rb
Direct Known Subclasses
Constant Summary collapse
- SELF_CLOSING =
Which tags are self closing (such tags ignore children).
[:img, :input]
- ESCAPE_HTML =
Borrowed from Rack::Utils, map of single character strings to html escaped versions.
{"&" => "&", "<" => "<", ">" => ">", "'" => "'", '"' => """}
- ESCAPE_HTML_PATTERN =
A regexp that matches all html characters requiring escaping.
Regexp.union(*ESCAPE_HTML.keys)
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#form ⇒ Object
Returns the value of attribute form.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#close ⇒ Object
Return opening half of tag, or nothing tag if self closing.
-
#initialize(form, type, attributes = {}) ⇒ Tag
constructor
Create a new tag.
-
#open ⇒ Object
Return opening half of tag, or entire tag if self closing.
Constructor Details
#initialize(form, type, attributes = {}) ⇒ Tag
Create a new tag.
98 99 100 101 102 |
# File 'lib/input.rb', line 98 def initialize(form, type, attributes={}) @form = form @type = type @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
83 84 85 |
# File 'lib/input.rb', line 83 def attributes @attributes end |
#form ⇒ Object
Returns the value of attribute form.
81 82 83 |
# File 'lib/input.rb', line 81 def form @form end |
#type ⇒ Object
Returns the value of attribute type.
82 83 84 |
# File 'lib/input.rb', line 82 def type @type end |
Instance Method Details
#close ⇒ Object
Return opening half of tag, or nothing tag if self closing
120 121 122 123 124 125 126 |
# File 'lib/input.rb', line 120 def close if SELF_CLOSING.include?(type) "" else "</#{type}>" end end |
#open ⇒ Object
Return opening half of tag, or entire tag if self closing
108 109 110 111 112 113 114 |
# File 'lib/input.rb', line 108 def open if SELF_CLOSING.include?(@type) "<#{@type}#{attr_html(attributes)}/>" else "<#{@type}#{attr_html(attributes)}>" end end |