[parenscript-devel] Generating HTML in parenscript

Gary King gwking at metabang.com
Fri Dec 7 03:15:32 UTC 2007


I've just started playing with Parenscript and feel confused about  
HTML generation. Since Parenscript already includes (the unexported)  
process-html-forms, it seems to be able to (almost) handle much of the  
logic for simple HTML generation. Consider that

> (parenscript::process-html-forms
>      `(:html
>        (:head (:title "ParenScript tutorial: 1st example"))
>        (:body (:h1 "ParenScript tutorial: 1st example")
> 	      (:p "Please click the link below." :br
> 		  ((:a :href "#" :onclick ,(ps-inline
> 					    (alert "Hello World")))
> 		   "Hello World")))))

produces

> (+ "<html/><head><title>ParenScript tutorial: 1st example</title></ 
> head><body><h1>ParenScript tutorial: 1st example</h1><p>Please click  
> the link below.<br/><a href=\"#\" onclick=\"javascript:alert(\"Hello  
> World\")\">Hello World</a></p></body>")

It's easy to refactor process-html-forms to arrive at the (slightly  
incorrect) HTML in a string:

> "<html/><head><title>ParenScript tutorial: 1st example</title></ 
> head><body><h1>ParenScript tutorial: 1st example</h1><p>Please click  
> the link below.<br/><a href=\"#\" onclick=\"javascript:alert(\"Hello  
> World\")\">Hello World</a></p></body>"


and probably easy to futz with *js-inline-string-delimiter* and the  
like to get the correct quotes around the body of the onclick handler.

So... since Parenscript doesn't do this, I have to ask "Why not"?! It  
would be nice to use Parenscript for simple HTML generation without  
having to get (Portable) AServe or some other more full-featured HTML  
generator. Am I missing something?

thanks,
--
Gary Warren King, metabang.com
Cell: (413) 559 8738
Fax: (206) 338-4052
gwkkwg on Skype * garethsan on AIM







More information about the parenscript-devel mailing list