HTM
Submitted by bingomanatee on 6 March, 2010 - 11:08
This library is a suite of functions to produce HTML from configuration objects. while there is no reason not to use static markup if you have settled into a specific pattern, if you want your markup to vary dynamically, this library can be a useful ways to assemble nodes. This is very much a "work in process" but I hope that someone doing a simiar dynamic HTML library might find the source useful.
Functions ($.fn.htm. ...)
- tag(name, options)
- a single "<" .. ">" expression. This function DOES NOT render a complete DOM node - you have to call it TWICE to include the close tag. Also all the other functions listed respond to the following options since they all decorate this function.
options: an object with one or more of the following properties:- class(optional): the name of the tag's class
- id(optional): the name of the tag's id
- props(optional): an array of name/value objects as in (for, say, a textarea tag):
[ {name: 'rows', value: 3}, {name: 'cols', value: 40}, {name: 'style', value: 'font-family: "Courier New",monospace'} ] - end(optional): include the '/' after the OPENING caret to create a closure tag (such as </textarea>).
- close(optional): include the '/' before the CLOSING caret to create a close tag (such as <img />).
- link(options):
- an "a" tag, hyperlinking a block of text to an external page.
options:- href: the URI of the target. can be omittted for anchor.
- body: The content to be linked.
- row(options):
- A table row.
options:- row_class: The name of the class attached to the <tr> tag.
- cells: an array of cells (see the _cell_map api below).
- _cell_map(options):
- An internal function that renders the cells of the row() function above.
options:- type(optional): td or th, default = td
- body: The content of the cell.
- div(options):
- a div node, with included body. This function is a good prototype for any
options:- body: The content of the div.
-
| Attachment | Size |
|---|---|
| htm.js.txt | 2.58 KB |

Post new comment