(examples-for html-tag
("returns a html string" (html-tag "div" { class 'yellow style (to-css { border "1px solid blue" font-size "3em" }) } (html-tag "h1" nil "Welcome") (html-tag "p" { class "yadda" } "blah blah")) "<div class='yellow' style='border:1px solid blue;font-size:3em;'><h1>Welcome</h1><p class='yadda'>blah blah</p></div>"))
(examples-for img
("returns an img tag" (img "/assets/face.png") "<img src='/assets/face.png'/>"))
(examples-for a
("returns an anchor tag" (link-to "click here!" "/other-page.html" { class "turbo" }) "<a href='/other-page.html' class='turbo'>click here!</a>"))
(examples-for link-if-txt
("returns nil if no text" (link-if-txt nil "/path" { class "winner" }) nil) ("returns link if text" (link-if-txt "click me" "/path" { class "winner" }) "<a href='/path' class='winner'>click me</a>"))
(examples-for percent-syntax
("generates a simple html tag" (%p "hello, world") "<p>hello, world</p>") ("generates a self-closing html tag" (%br/) "<br/>") ("generates nested html tags" (%p "hello " (%b "you") " over " (%i "there")) "<p>hello <b>you</b> over <i>there</i></p>") ("generates html tags with classnames" (%p "hello " (%b.thick "you") " over " (%i "there")) "<p>hello <b class='thick'>you</b> over <i>there</i></p>") ("concatenates content" (%p (map λx(%span.hello x) '(a b c))) "<p><span class='hello'>a</span><span class='hello'>b</span><span class='hello'>c</span></p>") ("generates html tags with multiple classnames" (%p "hello " (%b.thick.dense "you") " over " (%i "there")) "<p>hello <b class='thick dense'>you</b> over <i>there</i></p>") ("combine with colon syntax : precompile" (pre-compile:car:parse "%th:len") (fn args ((fn args (apply html-tag "th" nil args)) (apply len args)))) ("combine with colon syntax" (%th:len "foobar") "<th>6</th>") ("does not insert empty 'brace-list for no attributes" (pre-compile '(%p foo)) ((fn args (apply html-tag "p" nil args)) foo))
(examples-for prefix-list
("generates a simple html tag with attributes" (%a(href "/fr/index") "click here") "<a href='/fr/index'>click here</a>") ("generates a self-closing html tag with attributes" (%img/(src "/smile.png")) "<img src='/smile.png'/>") ("generates a self-closing html tag with attributes and classes" (%img/.round(src "/smile.png")) "<img class='round' src='/smile.png'/>") ("generates nested html tags with attributes" (%p(class 'important) "read this and " (%a(href "/fr/index") "click here") "!") "<p class='important'>read this and <a href='/fr/index'>click here</a>!</p>") ("generates nested html tags with classnames and other attributes" (%p(class 'important) "read this and " (%a.wow(href "/fr/index") "click here") "!") "<p class='important'>read this and <a class='wow' href='/fr/index'>click here</a>!</p>"))