module Trenni::Formatters::HTML::LabelForm

Public Instance Methods

checkbox(**options) click to toggle source

A checkbox field.

# File lib/trenni/formatters/html/label_form.rb, line 94
def checkbox(**options)
        options = @options.merge(**options)
        
        Builder.fragment do |builder|
                builder.inline(:label) do
                        builder.inline :input, :type => :hidden, :name => name_for(**options), :value => 'false'
                        
                        builder.inline(:span) do
                                if details = details_for(**options)
                                        builder.inline(:small) {builder.text details}
                                end
                        end
                        
                        builder.tag :input, checkbox_attributes_for(**options)
                        
                        # We would like a little bit of whitespace between the checkbox and the title:
                        builder.text " " + title_for(**options)
                end
        end
end
element(klass, **options, &block) click to toggle source
# File lib/trenni/formatters/html/label_form.rb, line 125
def element(klass, **options, &block)
        options = @options.merge(**options)
        buffer = Trenni::Template.buffer(block.binding)
        
        Builder.fragment(buffer) do |builder|
                builder.inline(:label) do
                        builder.inline(:span) do
                                builder.text title_for(**options)
                                
                                if details = details_for(**options)
                                        builder.inline(:small) {builder.text details}
                                end
                        end
                        
                        klass.call(self, builder, **options, &block)
                end
        end
end
input(**options) click to toggle source

An input field (single line text).

# File lib/trenni/formatters/html/label_form.rb, line 35
def input(**options)
        options = @options.merge(**options)
        
        Builder.fragment do |builder|
                builder.inline(:label) do
                        builder.inline(:span) do
                                builder.text title_for(**options)
                                
                                if details = details_for(**options)
                                        builder.inline(:small) {builder.text details}
                                end
                        end
                        
                        builder.inline :input, input_attributes_for(**options)
                end
        end
end
output(**options) click to toggle source

An output field for the result of a computation.

# File lib/trenni/formatters/html/label_form.rb, line 54
def output(**options)
        options = @options.merge(**options)
        
        builder.inline(:label) do
                builder.inline(:span) do
                        builder.text title_for(**options)
                        
                        if details = details_for(**options)
                                builder.inline(:small) {builder.text details}
                        end
                end
                
                builder.inline :output, output_attributes_for(**options) do
                        builder.text value_for(**options)
                end
        end
end
submit(**options) click to toggle source

A submission button

# File lib/trenni/formatters/html/label_form.rb, line 116
def submit(**options)
        options = @options.merge(**options)
        options[:title] ||= submit_title_for(**options)
        
        Builder.fragment do |builder|
                builder.inline :input, submit_attributes_for(**options)
        end
end
textarea(**options) click to toggle source

A textarea field (multi-line text).

# File lib/trenni/formatters/html/label_form.rb, line 73
def textarea(**options)
        options = @options.merge(**options)
        
        Builder.fragment do |builder|
                builder.inline(:label) do
                        builder.inline(:span) do
                                builder.text title_for(**options)
                                
                                if details = details_for(**options)
                                        builder.inline(:small) {builder.text details}
                                end
                        end
                        
                        builder.tag :textarea, textarea_attributes_for(**options) do
                                builder.text value_for(**options)
                        end
                end
        end
end