Do yourself a favor and import the module as from htmlgen import nil and then fully qualify the macros.
Note: The Karax project (nimble install karax) has a better way to achieve the same, see https://github.com/pragmagic/karax/blob/master/tests/nativehtmlgen.nim for an example.
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.
Examples
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>
用例:
let nim = "Nim" assert h1(a(href = "http://nim-lang.org", nim)) == """<h1><a href="http://nim-lang.org">Nim</a></h1>""" assert form(action = "test", `accept - charset` = "Content-Type") == """<form action="test" accept-charset="Content-Type"></form>"""
定数
coreAttr = " accesskey class contenteditable dir hidden id lang spellcheck style tabindex title translate "
- HTML DOM Core Attributes Source Edit
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 "
- HTML DOM Event Attributes Source Edit
ariaAttr = " role "
- HTML DOM Aria Attributes Source Edit
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 "
- HTML DOM Common Attributes Source Edit
マクロ
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 center(e: varargs[untyped]): untyped
- Generates the HTML center 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 details(e: varargs[untyped]): untyped
- Generates the HTML details element. ソース 編集
macro dfn(e: varargs[untyped]): untyped
- generates the HTML dfn element. ソース 編集
macro dialog(e: varargs[untyped]): untyped
- Generates the HTML dialog 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 marquee(e: varargs[untyped]): untyped
- Generates the HTML marquee 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 picture(e: varargs[untyped]): untyped
- Generates the HTML picture 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 slot(e: varargs[untyped]): untyped
- Generates the HTML slot 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 summary(e: varargs[untyped]): untyped
- Generates the HTML summary 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. ソース 編集