Class: Campo::Span

Inherits:
Base
  • Object
show all
Defined in:
lib/campo/campo.rb

Overview

add whatever you need to with a literal

Constant Summary

Constants inherited from Base

Base::DEFAULT

Instance Attribute Summary

Attributes inherited from Base

#attributes, #attributes The element's html attributes., #fields, #fields The element's child elements.

Attributes included from Childish

#parent

Instance Method Summary collapse

Methods inherited from Base

#each, #labelled, #on_output, #output, output, quotable, unhash

Methods included from Convenience

#bit_of_ruby, #checkbox, #fieldset, #hidden, #input, #literal, #password, #radio, #select, #submit, #text, #textarea

Methods included from Iding

#id_tag

Methods included from Childish

#push=

Constructor Details

#initialize(id, inner, attributes = {}) ⇒ Span

Returns a new instance of Span.



738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
# File 'lib/campo/campo.rb', line 738

def initialize( id, inner, attributes={} )
  if inner.kind_of? Hash
    attributes = inner
    inner = nil
  end
  super( id, attributes )
  @attributes.delete(:name) # only id for this element
  @inner = inner
  
  unless @inner.nil? or @inner.empty?
    self.fields.push Campo.literal(@inner)
  end
  
  self.on_output do |n=0, tab=2|
    %Q!#{" " * n * tab}%span{#{Base.unhash( @attributes )}}!
  end
  self
end