(examples-for html-build-interpolator
("takes out all the non-string bits, concatenates, converts to html, then splices in all the bits again"
(html-build-interpolator (list "<h1>" '(foo 1 2 3) "</h1>")
{ method (curry string-replace "h1" "HEADER-1")
esc x1 })
(string-pieces "<HEADER-1>" (interpolate (foo 1 2 3)) "</HEADER-1>")))
(examples-for render-as-html
("return the same string if there are no interpolations"
(pre-compile '(render-as-html "<p>hello, nydp</p>"))
"<p>hello, nydp</p>")
("return the same thing if there are no interpolations"
(pre-compile '(render-as-html (foo bar yobo)))
(foo bar yobo))
("compile a string with interpolations to an instruction to generate haml"
(pre-compile '(render-as-html "<h1>HEADER</h1>
<p>~a and ~b and ~(c 3)</p> <ul>
<li>item ~(assign counter (+ counter 1))</li> <li>item ~(assign counter (+ counter 1))</li> <li>item ~(assign counter (+ counter 1))</li>
</ul> “))
(string-pieces "<h1>HEADER</h1>\n<p>"
(interpolate a) " and " (interpolate b) " and " (interpolate (c 3))
"</p>\n<ul>\n <li>item " (interpolate (assign counter (+ counter 1)))
"</li>\n <li>item " (interpolate (assign counter (+ counter 1)))
"</li>\n <li>item " (interpolate (assign counter (+ counter 1)))
"</li>\n</ul>\n")))
(examples-for strip-nydp-tags
("does nothing to an empty string"
(strip-nydp-tags "")
"")
("does nothing to an ordinary string with no nydp tag"
(strip-nydp-tags "hello nothing to see here")
"hello nothing to see here")
("removes <nydp> and </nydp> tags from given string"
(strip-nydp-tags "blah blah <nydp>\~(blah)</nydp> more blah")
"blah blah \~(blah) more blah"))