Borges::HtmlBuilder (Class)

In: lib/Borges/HTML/HtmlBuilder.rb
Parent: Object

Borges::HTMLBuilder is a generic class for outputting HTML.

Constants

SIMPLE_ELEMENTS = { :bold => :b, :code => :code, :div => :div, :emphasis => :em, :italic => :i, :paragraph => :p, :preformatted => :pre, :strong => :strong, :small => :small, :span => :span, :sub => :sub, :sup => :sup, :table_data => :td, :table_heading => :th, :underline => :u, }
HTML_CHARACTERS = {}

Attributes

attributes  [R] 
document  [RW] 

Public Class methods

Creates a new HtmlBuilder.

document must have the following interface:

  #head
  #add_element
  #pop_element
  #push_element

Public Instance methods

Creates a line break.

Close the last open element.

Adds a class attribute that contains classes

Creates a <div> that has an id attribute containing name.

Creates a <div> that has an class attribute containing classes.

Adds an id attribute containing e_id

Turns an obj into an HTML encoded string

encode "foo > bar" # => "foo &gt; bar"

Adds obj as an HTML encoded string.

Creates a <fieldset> labeled legend

Creates a tag that goes in the <head> of the document with name.

Creates a tag that goes in the <head> of the document with name, that contains child in its contents.

Creates a level 1 heading

heading("My Heading")

<h1>My Heading</h1>

Creates a heading with level

heading_level("My Heading", 2)

<h2>My Heading</h2>

Adds an <hr> to the document.

Adds an <img> with src as its src attribute. If alt is specified, it is used as the image’s alternate text, otherwise the alt attribute is left empty.

Add an anchor on an <img> with src as its src attribute. If alt is specified, it is used as the image’s alternate text, otherwise the alt attribute is left empty.

Creates an <input> of type input_type with an optional name and value.

Builds an unordered list of items from an Enumerable. text will be called on each item.

list ["x", 5, { :x => :y }]

<ul><li>x</li><li>5</li><li>xy</li></ul>

Builds an unordered list of items from an Enumerable. The given block will be called on each item.

See also list

Adds a new element name to the document with all the attributes specified for it.

Renders obj.

Creates a <script> that links to url

Adds a non-breakin space (&nbsp;).

Adds a link to an external stylesheet with url.

Creates a <table> element.

Creates a row of table headings from headings

Creates a table row.

Creates a table row with label in the first cell.

Creates a table row with a table cell that spans span columns.

Creates a table row containing a single data cell.

Creates an empty table row.

Creates an empty element with name

Creates a name element containing obj

Turn an object into a string. It is not recommened to use this method to dump raw HTML.

text("hello world")

hello world

Sets the <title> of the document to str

Creates an anchor that links to url.

[Validate]