Elements - Generic Elements

Generic Elements

Source code: hyccup/element.hy

Functions for creating generic HTML elements.

(hyccup.element.image)

Create an image element.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • src – The source of the image

  • alt – Alternative text for the image

(hyccup.element.javascript-tag script)

Wrap the supplied javascript up in script tags and a CDATA section.

Wrap some content in a HTML hyperlink with the supplied URL.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • url – The hypertext link

  • *content – Content do include as children

(hyccup.element.mail-to)

Wrap some content in a HTML hyperlink with the supplied e-mail address.

If no content provided use the e-mail address as content.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • email – E-mail address

  • *content – Content do include as children

(hyccup.element.ordered-list)

Wrap a collection in an ordered list.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • coll – Collection of elements of the list.

(hyccup.element.unordered-list)

Wrap a collection in an unordered list.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • coll – Collection of elements of the list.

Form Elements

Source code: hyccup/form.hy

Functions for generating HTML forms and input fields.

(hyccup.form.check-box)

Create a check box.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • name – The name of the checkbox

  • checked? – Boolean attribute “checked” (default: None)

  • value – Its value (default: “true”)

(hyccup.form.drop-down)

Create a drop-down box using the <select> tag.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • options – A collection of options (passed to select-options)

  • selected – Selected option (passed to select-options)

(hyccup.form.email-field)

Create a new email input field.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • name – The name of the field

  • value – Its value (default: None)

(hyccup.form.file-upload)

Create a file upload input.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • name – The name of the field

(hyccup.form.form-to)

Create a form that points to a particular method and route.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • method-and-action – collection containing method and action (e.g. ['post "/foo"])

  • *body – The body of the form

(hyccup.form.group #* args #** kwds)

Group together a set of related form fields.

(hyccup.form.hidden-field)

Create a hidden input field.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • name – The name of the field

  • value – Its value (default: None)

(hyccup.form.input-field type name value)

Create a new <input> element.

(hyccup.form.label)

Create a label for an input field with the supplied name.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • name – The name of the field

  • text – Its text

(hyccup.form.make-id name)

Create a field id from the supplied argument and current field group.

(hyccup.form.make-name name)

Create a field name from the supplied argument the current field group.

(hyccup.form.password-field)

Create a new password field.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • name – The name of the field

  • value – Its value (default: None)

(hyccup.form.radio-button)

Create a radio button.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • group – The group of the radio button

  • checked? – Boolean attribute “checked” (default: None)

  • value – Its value (default: “true”)

(hyccup.form.reset-button)

Create a form reset button.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • name – The text of the button

(hyccup.form.select-options)

Create a seq of option tags from a collection.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • coll – Collection of options. Items should be (text, val)

  • selected – Selected item (an available value) (default: None)

(hyccup.form.submit-button)

Create a submit button.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • name – The text of the button

(hyccup.form.text-area)

Create a text area element.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • name – The name of the text area

  • value – Its value (default: None)

(hyccup.form.text-field)

Create a new text input field.

Parameters
  • attrs-map – Optional dict of attributes as first positional parameter

  • name – The name of the field

  • value – Its value (default: None)