class Forme::Tag

  1. lib/forme/tag.rb
Superclass: Object

Low level abstract tag form, where each instance represents a html tag with attributes and children.

Methods

Public Class

  1. new

Public Instance

  1. <<
  2. attr
  3. children
  4. form
  5. tag
  6. to_s
  7. type

Attributes

attr [R]

The attributes hash of this receiver.

children [R]

An array instance representing the children of the receiver, or possibly nil if the receiver has no children.

form [R]

The Form object related to the receiver.

type [R]

The type of tag, should be a symbol (e.g. :input, :select).

Public Class methods

new (form, type, attr={}, children=nil)

Set the form, type, attr, and children.

[show source]
# File lib/forme/tag.rb, line 20
def initialize(form, type, attr={}, children=nil)
  @form, @type, @attr = form, type, (attr||{})
  @children = parse_children(children)
end

Public Instance methods

<< (child)

Adds a child to the array of receiver's children.

[show source]
# File lib/forme/tag.rb, line 26
def <<(child)
  if children
    children << child
  else
    @children = [child]
  end
end
tag (*a, &block)

Create a new Tag instance with the given arguments and block related to the receiver's form.

[show source]
# File lib/forme/tag.rb, line 36
def tag(*a, &block)
  form._tag(*a, &block)
end
to_s ()

Return a string containing the serialized content of the receiver.

[show source]
# File lib/forme/tag.rb, line 41
def to_s
  form.raw_output(Forme.transform(:serializer, @opts, @form.opts, self))
end