W3cubDocs

/Nim

Module htmlgen

Warning: This module uses immediate macros which are known to cause problems. Do yourself a favor and import the module as from htmlgen import nil and then fully qualify the macros.

This module implements a simple XML and HTML code generator. Each commonly used HTML tag has a corresponding macro that generates a string with its HTML representation.

Example:

var nim = "Nim"
echo h1(a(href="http://nim-lang.org", nim))

Writes the string:

<h1><a href="http://nim-lang.org">Nim</a></h1>

Imports

macros, strutils

Consts

coreAttr = " id class title style "
eventAttr = " onclick ondblclick onmousedown onmouseup onmouseover onmousemove onmouseout onkeypress onkeydown onkeyup onload "
commonAttr = " id class title style  onclick ondblclick onmousedown onmouseup onmouseover onmousemove onmouseout onkeypress onkeydown onkeyup onload "

Procs

proc xmlCheckedTag(e: NimNode; tag: string; optAttr = ""; reqAttr = ""; isLeaf = false): NimNode {.
    compileTime, raises: [], tags: [].}
use this procedure to define a new XML tag

Macros

macro a(e: varargs[untyped]): untyped
generates the HTML a element.
macro acronym(e: varargs[untyped]): untyped
generates the HTML acronym element.
macro address(e: varargs[untyped]): untyped
generates the HTML address element.
macro area(e: varargs[untyped]): untyped
generates the HTML area element.
macro b(e: varargs[untyped]): untyped
generates the HTML b element.
macro base(e: varargs[untyped]): untyped
generates the HTML base element.
macro big(e: varargs[untyped]): untyped
generates the HTML big element.
macro blockquote(e: varargs[untyped]): untyped
generates the HTML blockquote element.
macro body(e: varargs[untyped]): untyped
generates the HTML body element.
macro br(e: varargs[untyped]): untyped
generates the HTML br element.
macro button(e: varargs[untyped]): untyped
generates the HTML button element.
macro caption(e: varargs[untyped]): untyped
generates the HTML caption element.
macro cite(e: varargs[untyped]): untyped
generates the HTML cite element.
macro code(e: varargs[untyped]): untyped
generates the HTML code element.
macro col(e: varargs[untyped]): untyped
generates the HTML col element.
macro colgroup(e: varargs[untyped]): untyped
generates the HTML colgroup element.
macro dd(e: varargs[untyped]): untyped
generates the HTML dd element.
macro del(e: varargs[untyped]): untyped
generates the HTML del element.
macro dfn(e: varargs[untyped]): untyped
generates the HTML dfn element.
macro `div`(e: varargs[untyped]): untyped
generates the HTML div element.
macro dl(e: varargs[untyped]): untyped
generates the HTML dl element.
macro dt(e: varargs[untyped]): untyped
generates the HTML dt element.
macro em(e: varargs[untyped]): untyped
generates the HTML em element.
macro fieldset(e: varargs[untyped]): untyped
generates the HTML fieldset element.
macro form(e: varargs[untyped]): untyped
generates the HTML form element.
macro h1(e: varargs[untyped]): untyped
generates the HTML h1 element.
macro h2(e: varargs[untyped]): untyped
generates the HTML h2 element.
macro h3(e: varargs[untyped]): untyped
generates the HTML h3 element.
macro h4(e: varargs[untyped]): untyped
generates the HTML h4 element.
macro h5(e: varargs[untyped]): untyped
generates the HTML h5 element.
macro h6(e: varargs[untyped]): untyped
generates the HTML h6 element.
generates the HTML head element.
macro html(e: varargs[untyped]): untyped
generates the HTML html element.
macro hr(): untyped
generates the HTML hr element.
macro i(e: varargs[untyped]): untyped
generates the HTML i element.
macro img(e: varargs[untyped]): untyped
generates the HTML img element.
macro input(e: varargs[untyped]): untyped
generates the HTML input element.
macro ins(e: varargs[untyped]): untyped
generates the HTML ins element.
macro kbd(e: varargs[untyped]): untyped
generates the HTML kbd element.
macro label(e: varargs[untyped]): untyped
generates the HTML label element.
macro legend(e: varargs[untyped]): untyped
generates the HTML legend element.
macro li(e: varargs[untyped]): untyped
generates the HTML li element.
generates the HTML link element.
macro map(e: varargs[untyped]): untyped
generates the HTML map element.
macro meta(e: varargs[untyped]): untyped
generates the HTML meta element.
macro noscript(e: varargs[untyped]): untyped
generates the HTML noscript element.
macro `object`(e: varargs[untyped]): untyped
generates the HTML object element.
macro ol(e: varargs[untyped]): untyped
generates the HTML ol element.
macro optgroup(e: varargs[untyped]): untyped
generates the HTML optgroup element.
macro option(e: varargs[untyped]): untyped
generates the HTML option element.
macro p(e: varargs[untyped]): untyped
generates the HTML p element.
macro param(e: varargs[untyped]): untyped
generates the HTML param element.
macro pre(e: varargs[untyped]): untyped
generates the HTML pre element.
macro q(e: varargs[untyped]): untyped
generates the HTML q element.
macro samp(e: varargs[untyped]): untyped
generates the HTML samp element.
macro script(e: varargs[untyped]): untyped
generates the HTML script element.
macro select(e: varargs[untyped]): untyped
generates the HTML select element.
macro small(e: varargs[untyped]): untyped
generates the HTML small element.
macro span(e: varargs[untyped]): untyped
generates the HTML span element.
macro strong(e: varargs[untyped]): untyped
generates the HTML strong element.
macro style(e: varargs[untyped]): untyped
generates the HTML style element.
macro sub(e: varargs[untyped]): untyped
generates the HTML sub element.
macro sup(e: varargs[untyped]): untyped
generates the HTML sup element.
macro table(e: varargs[untyped]): untyped
generates the HTML table element.
macro tbody(e: varargs[untyped]): untyped
generates the HTML tbody element.
macro td(e: varargs[untyped]): untyped
generates the HTML td element.
macro textarea(e: varargs[untyped]): untyped
generates the HTML textarea element.
macro tfoot(e: varargs[untyped]): untyped
generates the HTML tfoot element.
macro th(e: varargs[untyped]): untyped
generates the HTML th element.
macro thead(e: varargs[untyped]): untyped
generates the HTML thead element.
macro title(e: varargs[untyped]): untyped
generates the HTML title element.
macro tr(e: varargs[untyped]): untyped
generates the HTML tr element.
macro tt(e: varargs[untyped]): untyped
generates the HTML tt element.
macro ul(e: varargs[untyped]): untyped
generates the HTML ul element.
macro `var`(e: varargs[untyped]): untyped
generates the HTML var element.

© 2006–2017 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/htmlgen.html