3 ms·
It would seem possible to write a Lisp library that does exactly what you described; albeit indirectly. The library would interpret Lisp data structures and ret
by bradleyland 16y ago
It would seem possible to write a Lisp library that does exactly what you described; albeit indirectly. The library would interpret Lisp data structures and return well-formed XHTML. Think Haml, only Lisp. If someone were interested in doing this, they should definitely have a look at Haml though. There are some interesting methods for telling the Haml interpreter how you want the content handled. Built-in support for escaping characters, expansion/non-expansion, etc is really nice.
I know very little about Lisp, so this type of thing might already exist.
- dmm 16y agoThere are probably dozens lisp libraries that do exactly this. Pretty much every lisp developer writes one. A bunch can be found here: http://www.cliki.net/Lisp%20Markup%20Languages http://www.cliki.net/Lisp%20Markup%20Languages Examples: http://www.cliki.net/HTML-TEMPLATE http://www.cliki.net/HTML-TEMPLATE http://www.nicklevine.org/play/xhtml.lisp http://www.nicklevine.org/play/xhtml.lisp http://www.cliki.net/yaclml http://www.cliki.net/yaclml http://www.cliki.net/CL-WHO http://www.cliki.net/CL-WHO
- spooneybarger 16y agoThere are already lisp/scheme libraries out there that do that. The smalltalk framework's Seaside and Illiad both contain the same as well. as a basic example from seaside: renderContentOn: html html heading level: 1; with: 'Hello World!'. creates <h1>Hello World</h1> More on how Seaside generates html can be found at: http://seaside.st/documentation/generating-html http://seaside.st/documentation/generating-html Here is an example from racket ( aka plt scheme ): (define (build-request-page label next-url hidden) `(html (head (title "Enter a Number to Add")) (body ([bgcolor "white"]) (form ([action ,next-url] [method "get"]) ,label (input ([type "text"] [name "number"] [value ""])) (input ([type "hidden"] [name "hidden"] [value ,hidden])) (input ([type "submit"] [name "enter"] [value "Enter"])))))) More ( and the proper formatting of the above ) can be seen at: http://docs.racket-lang.org/more/#(part.__.Hello_.World__.Server) http://docs.racket-lang.org/more/#(part.__.Hello_.World__.Se...
- draegtun 16y agoAnd there are also libraries in other languages as well. For eg: * There's Builders in Groovy (http://groovy.codehaus.org/Builders http://groovy.codehaus.org/Builders) * Markaby in Ruby (http://en.wikipedia.org/wiki/Markaby http://en.wikipedia.org/wiki/Markaby) * and Markapl and Template::Declare in Perl (http://search.cpan.org/perldoc/Markapl http://search.cpan.org/perldoc/Markapl & http://search.cpan.org/perldoc/Template%3A%3ADeclare http://search.cpan.org/perldoc/Template%3A%3ADeclare). Here is the snippet in blogpost using Markapl: div('.red') { p { "hello world" } } Also see related HN: http://news.ycombinator.com/item?id=705698 http://news.ycombinator.com/item?id=705698
- spooneybarger 16y agoMy only problem with markaby is that all the do ... end for blocks sort of defeats the purpose for me. not completely but partially. that said, i often use it.
- kroger 16y agoYes, they do exist. Check, for instance: http://weitz.de/cl-who/ http://weitz.de/cl-who/ and http://weitz.de/cl-who/ http://weitz.de/cl-who/