Class: Borges::HtmlRenderer

# Borges::HtmlRenderer (Class)

In: | lib/Borges/HTML/HtmlRenderer.rb
Parent: | Object

Renderer for HTML with callbacks

## Methods

action_callback anchor anchor_on boolean_menu boolean_menu_on checkbox default_action default_action_on download_link file_upload form image_anchor label_for new open_anchor open_form open_select option password_input password_input_on radio_button radio_group select setter_callback style submit_button submit_button_on text_area text_area_on text_input text_input_on url_for url_for_document value_input

## Attributes

action_url | [RW] |
callbacks | [RW] |
rendering_context | [RW] |

## Public Class methods

new(rendering_context)

## Public Instance methods

action_callback(message, object)

Creates a callback that sends `message` to `object` with zero arguments.

anchor(anchor_text, &block)

Creates a link with `anchor_text` that executes a block when clicked.

anchor_on(sym, obj)

Creates a link that calls `sym` on `obj` when clicked. `sym` is used as the title for the link.

boolean_menu(bool, labels = [:Yes, :No], &block)

Creates a <select> menu of two choices with `labels` (default to Yes and No). If `bool` is true, the first item is the default.

boolean_menu_on(sym, obj)

Creates a menu that picks the default value by calling `sym` on `obj`.

checkbox(checked = false, &block)

Creates a checkbox. The checkbox will be initially checked if `checked` is set to true.

default_action(&block)

Creates a default action that gets called when the form is submitted.

default_action_on(message, object)

Creates a default action that sends `message` to `object`. `message` is sent with zero arguments.

download_link(object, text, mime_type = nil)

Creates a link to download `object` with the text of `text`. `mime_type` will default to text/plain.

to_s will be sent to `object`, and the resulting string will be returned to the user.

WARNING! A download link created by this method will remain live until Borges is shut down. The space used will not be reclaimed. If you are creating many download links, you may wish to serve them from outside Borges.

file_upload(&block)

Creates a file upload field.

form(&block)

Create a form.

image_anchor(img_url, alt='', &block)

Creates a link with image from img_url as content. The link executes `block` when executed. Image has alt text of `alt`.

label_for(sym)

Turn `sym` into a capitalized label.

open_anchor(&block)
open_form()
open_select()
option(label, selected = false, &callback)

Creates an option for a <select>. `label` sets the label for the select. The option will be selected if `selected` is true.

password_input(value = "", &callback)

Creates a password input containing `value`. It is however not a good idea to output the current password to html, since the user can retrieve it by looking at the source.

password_input_on(sym, obj)

Creates a password input that gets its value by calling `sym` to `obj`, then calls `sym`= to `obj` when submitted.

radio_button(group, checked = false, &block)

Creates a radio button that is part of radio group `group`. The radio button will be checked if `checked` is true.

`group` must come from a previous radio_group:

      group = r.radio_group
      r.radio_button(group) do ... end

radio_group()

Creates a default action for a radio group.

select(list, selected = nil, &callback)

Creates a <select> from `list`.

Calls each on `list` and if `list` yields a single item, then to_s will be called on the item for use as the label. If `list` yields two items, then the second item will be used as a label.

If `selected` matches an item in `list`, that item will be selected.

`callback` will be passed the user-selected item.

setter_callback(attr, object)

Creates a callback that sets `attr` on `object`.

style(css)

Creates a new document containing `css`, and returns a URL for the document.

submit_button(label = 'Submit', &block)

Creates a submit button with a label of `label`, or ‘Submit’ if not given.

submit_button_on(sym, obj)

Creates a submit button with a label of `sym` that calls `sym` on `obj` when clicked.

text_area(value = "", &block)

Creates a textarea with `value` as its contents.

text_area_on(sym, obj)

Creates a <textarea> by using getter and setter methods for method `sym` on object `obj`.

text_input(value = "", &callback)

Creates a text input containing `value`.

text_input_on(sym, obj)

Creates a text input that gets its value by calling `sym` to `obj`, then calls `sym`= to `obj` when submitted.

url_for(&block)
url_for_document(obj, mime_type = nil)
value_input(input_type, value, &block)

[Validate]