Module: Campo::Convenience
- Included in:
- Base
- Defined in:
- lib/campo.rb
Overview
Iding
Instance Method Summary collapse
- #bit_of_ruby(*args) ⇒ Object (also: #haml_ruby_insert)
- #checkbox(name, label = nil, attributes = {}) ⇒ Object
- #fieldset(text, attributes = {}, &block) ⇒ Object
- #input(name, type, label = nil, attributes = {}) ⇒ Object
- #literal(*args) ⇒ Object
- #radio(name, label = nil, attributes = {}) ⇒ Object
- #select(*args, &block) ⇒ Object
- #submit(name = "Submit", label_inner = nil, attributes = {}) ⇒ Object
-
#text(name, label = nil, attributes = {}) ⇒ Input
Add an input with type of text.
- #textarea(*args) ⇒ Object
Instance Method Details
#bit_of_ruby(*args) ⇒ Object Also known as: haml_ruby_insert
40 41 42 43 44 |
# File 'lib/campo.rb', line 40 def bit_of_ruby( *args ) tag = Campo::Haml_Ruby_Insert.new( *args ) self << tag tag end |
#checkbox(name, label = nil, attributes = {}) ⇒ Object
96 97 98 |
# File 'lib/campo.rb', line 96 def checkbox( name, label=nil, attributes={} ) input( name, :checkbox, label, attributes ) end |
#fieldset(text, attributes = {}, &block) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/campo.rb', line 31 def fieldset( text, attributes={}, &block ) fieldset = (Fieldset.new(attributes) << Legend.new( text )) block.call( fieldset ) if block self << fieldset fieldset end |
#input(name, type, label = nil, attributes = {}) ⇒ Object
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/campo.rb', line 103 def input( name, type, label=nil, attributes={} ) if label.kind_of? Hash attributes = label label = nil end field = Campo::Input.new( name, type, attributes ).labelled( label ) self << field field end |
#literal(*args) ⇒ Object
50 51 52 53 54 |
# File 'lib/campo.rb', line 50 def literal( *args ) tag = Campo::Literal.new( *args ) self << tag tag end |
#radio(name, label = nil, attributes = {}) ⇒ Object
91 92 93 |
# File 'lib/campo.rb', line 91 def radio( name, label=nil, attributes={} ) input( name, :radio, label, attributes ) end |
#select(*args, &block) ⇒ Object
71 72 73 74 75 |
# File 'lib/campo.rb', line 71 def select( *args, &block ) select = Campo::Select.new( *args, &block ) self << select select end |
#submit(name = "Submit", label_inner = nil, attributes = {}) ⇒ Object
116 117 118 119 120 |
# File 'lib/campo.rb', line 116 def submit( name="Submit", label_inner=nil, attributes={} ) submit = Campo::Input.new( name, :submit, {value: name}.merge(attributes) ) self << submit submit end |
#text(name, label = nil, attributes = {}) ⇒ Input
Add an input with type of text
86 87 88 |
# File 'lib/campo.rb', line 86 def text( name, label=nil, attributes={} ) input( name, :text, label, attributes ) end |