Class: Forme::Tag
- Inherits:
-
Object
- Object
- Forme::Tag
- Defined in:
- lib/forme/tag.rb
Overview
Low level abstract tag form, where each instance represents an HTML tag with attributes and children.
Instance Attribute Summary collapse
-
#attr ⇒ Object
readonly
The attributes hash of this receiver.
-
#children ⇒ Object
readonly
An array instance representing the children of the receiver, or possibly
nilif the receiver has no children. -
#form ⇒ Object
readonly
The
Formobject related to the receiver. -
#type ⇒ Object
readonly
The type of tag, should be a symbol (e.g. :input, :select).
Instance Method Summary collapse
-
#initialize(form, type, attr = {}, children = nil) ⇒ Tag
constructor
Set the
form,type,attr, andchildren. -
#tag(*a, &block) ⇒ Object
Create a new
Taginstance with the given arguments and block related to the receiver’sform. -
#to_s ⇒ Object
Return a string containing the serialized content of the receiver.
Constructor Details
#initialize(form, type, attr = {}, children = nil) ⇒ Tag
Set the form, type, attr, and children.
21 22 23 24 |
# File 'lib/forme/tag.rb', line 21 def initialize(form, type, attr={}, children=nil) @form, @type, @attr = form, type, (attr||{}) @children = parse_children(children) end |
Instance Attribute Details
#attr ⇒ Object (readonly)
The attributes hash of this receiver.
14 15 16 |
# File 'lib/forme/tag.rb', line 14 def attr @attr end |
#children ⇒ Object (readonly)
An array instance representing the children of the receiver, or possibly nil if the receiver has no children.
18 19 20 |
# File 'lib/forme/tag.rb', line 18 def children @children end |
#form ⇒ Object (readonly)
The Form object related to the receiver.
8 9 10 |
# File 'lib/forme/tag.rb', line 8 def form @form end |
#type ⇒ Object (readonly)
The type of tag, should be a symbol (e.g. :input, :select).
11 12 13 |
# File 'lib/forme/tag.rb', line 11 def type @type end |
Instance Method Details
#tag(*a, &block) ⇒ Object
Create a new Tag instance with the given arguments and block related to the receiver’s form.
28 29 30 |
# File 'lib/forme/tag.rb', line 28 def tag(*a, &block) form._tag(*a, &block) end |