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 = " accesskey class contenteditable dir hidden id lang spellcheck style tabindex title translate "
eventAttr = "onabort onblur oncancel oncanplay oncanplaythrough onchange onclick oncuechange ondblclick ondurationchange onemptied onended onerror onfocus oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata onloadedmetadata onloadstart onmousedown onmouseenter onmouseleave onmousemove onmouseout onmouseover onmouseup onmousewheel onpause onplay onplaying onprogress onratechange onreset onresize onscroll onseeked onseeking onselect onshow onstalled onsubmit onsuspend ontimeupdate ontoggle onvolumechange onwaiting "
ariaAttr = " role "
commonAttr = " accesskey class contenteditable dir hidden id lang spellcheck style tabindex title translate onabort onblur oncancel oncanplay oncanplaythrough onchange onclick oncuechange ondblclick ondurationchange onemptied onended onerror onfocus oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata onloadedmetadata onloadstart onmousedown onmouseenter onmouseleave onmousemove onmouseout onmouseover onmouseup onmousewheel onpause onplay onplaying onprogress onratechange onreset onresize onscroll onseeked onseeking onselect onshow onstalled onsubmit onsuspend ontimeupdate ontoggle onvolumechange onwaiting  role "

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 abbr(e: varargs[untyped]): untyped
generates the HTML abbr element.
macro address(e: varargs[untyped]): untyped
generates the HTML address element.
macro area(e: varargs[untyped]): untyped
generates the HTML area element.
macro article(e: varargs[untyped]): untyped
generates the HTML article element.
macro aside(e: varargs[untyped]): untyped
generates the HTML aside element.
macro audio(e: varargs[untyped]): untyped
generates the HTML audio element.
macro b(e: varargs[untyped]): untyped
generates the HTML b element.
macro base(e: varargs[untyped]): untyped
generates the HTML base element.
macro bdi(e: varargs[untyped]): untyped
generates the HTML bdi element.
macro bdo(e: varargs[untyped]): untyped
generates the HTML bdo 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 canvas(e: varargs[untyped]): untyped
generates the HTML canvas 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 data(e: varargs[untyped]): untyped
generates the HTML data element.
macro datalist(e: varargs[untyped]): untyped
generates the HTML datalist 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 embed(e: varargs[untyped]): untyped
generates the HTML embed element.
macro fieldset(e: varargs[untyped]): untyped
generates the HTML fieldset element.
macro figure(e: varargs[untyped]): untyped
generates the HTML figure element.
macro figcaption(e: varargs[untyped]): untyped
generates the HTML figcaption element.
macro footer(e: varargs[untyped]): untyped
generates the HTML footer 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.
macro head(e: varargs[untyped]): untyped
generates the HTML head element.
macro header(e: varargs[untyped]): untyped
generates the HTML header 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 iframe(e: varargs[untyped]): untyped
generates the HTML iframe 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 keygen(e: varargs[untyped]): untyped
generates the HTML keygen 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.
macro link(e: varargs[untyped]): untyped
generates the HTML link element.
macro main(e: varargs[untyped]): untyped
generates the HTML main element.
macro map(e: varargs[untyped]): untyped
generates the HTML map element.
macro mark(e: varargs[untyped]): untyped
generates the HTML mark element.
macro meta(e: varargs[untyped]): untyped
generates the HTML meta element.
macro meter(e: varargs[untyped]): untyped
generates the HTML meter element.
macro nav(e: varargs[untyped]): untyped
generates the HTML nav 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 output(e: varargs[untyped]): untyped
generates the HTML output 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 progress(e: varargs[untyped]): untyped
generates the HTML progress element.
macro q(e: varargs[untyped]): untyped
generates the HTML q element.
macro rb(e: varargs[untyped]): untyped
generates the HTML rb element.
macro rp(e: varargs[untyped]): untyped
generates the HTML rp element.
macro rt(e: varargs[untyped]): untyped
generates the HTML rt element.
macro rtc(e: varargs[untyped]): untyped
generates the HTML rtc element.
macro ruby(e: varargs[untyped]): untyped
generates the HTML ruby element.
macro s(e: varargs[untyped]): untyped
generates the HTML s element.
macro samp(e: varargs[untyped]): untyped
generates the HTML samp element.
macro script(e: varargs[untyped]): untyped
generates the HTML script element.
macro section(e: varargs[untyped]): untyped
generates the HTML section element.
macro select(e: varargs[untyped]): untyped
generates the HTML select element.
macro small(e: varargs[untyped]): untyped
generates the HTML small element.
macro source(e: varargs[untyped]): untyped
generates the HTML source 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 `template`(e: varargs[untyped]): untyped
generates the HTML template 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 time(e: varargs[untyped]): untyped
generates the HTML time element.
macro title(e: varargs[untyped]): untyped
generates the HTML title element.
macro tr(e: varargs[untyped]): untyped
generates the HTML tr element.
macro track(e: varargs[untyped]): untyped
generates the HTML track element.
macro tt(e: varargs[untyped]): untyped
generates the HTML tt element.
macro u(e: varargs[untyped]): untyped
generates the HTML u element.
macro ul(e: varargs[untyped]): untyped
generates the HTML ul element.
macro `var`(e: varargs[untyped]): untyped
generates the HTML var element.
macro video(e: varargs[untyped]): untyped
generates the HTML video element.
macro wbr(e: varargs[untyped]): untyped
generates the HTML wbr element.

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