Subject: Re: markup languages and webdesigners
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 20 Jan 2006 05:31:58 -0600
Newsgroups: comp.lang.lisp
Message-ID: <HIedneXZ2v6zV03eRVn-ig@speakeasy.net>
Jonathan Heusser  <jonathan.heusser@gmx.net> wrote:
+---------------
| What I often wonder about when looking at the different markup languages
| available for common lisp: If you have webdesigners creating a big html
| website for you with lots of elements and well placed graphics, how do
| you bring together a markup language like CL-WHO (just as an example)
| and the html code of that site? My designers don't talk lisp.
+---------------

Several of the pages on <http://www.cliki.net/web> address this issue.
One approach is to embed some sort of escape code in the HTML that calls
out to Lisp, perhaps using the <% ... %> brackets that ASP, JSP, or LSP
use or the <?foo ... ?> bracketing that PHP or XML "processing" use.
The following shows one example of this style:

    http://www.cliki.net/CL-EMB
    http://common-lisp.net/project/cl-emb/examples.html

It can embed either raw Lisp such as calls to CL-WHO or HTOUT:

    <h1>Music links</h1>
    <%
    (cl-who:with-html-output (*standard-output*)
      (loop for (link . title) in 
	    '(("http://zappa.com/" . "Frank Zappa")
	      ("http://marcusmiller.com/" . "Marcus Miller")
	      ("http://www.milesdavis.com/" . "Miles Davis"))
	    do (cl-who:htm (:a :href link
			       (:b (cl-who:str title)))
			   :br)))
    %>

or or it also provides a kind of higher-level macro language:

    <h1>Music links</h1>
    <% @loop music-list %>
    <a href="<% @var link %>"><b><% @var title -escape html%></b></a><br />
    <% @endloop %>

Here are a few other packages picked at random that do similar things:

    http://www.cliki.net/clhp
    http://www.cliki.net/HTML-TEMPLATE
    http://www.cliki.net/KPAX
    http://www.cliki.net/LSP
    ...[there are more]...

Whichever you pick [or if you write your own], I would suggest that
you put as little actual Lisp within the brackets as possible [mainly
calls to pre-defined functions], and that you only allow complete
s-exprs within a bracketed expression. Otherwise it can be quite hard
to keep the Lisp parens and subforms balanced and/or nested properly
when there's a huge amount of raw HTML splitting them apart. About a
year ago, Frank Buss gave a tiny example of the "bad" style, which is
similar to the coding style one tends to find in JSP & PHP pages, too:

    <% (dotimes (i 10) %>
      <img src="mr-yuck.jpg">
    <% ) %>

Finally, it's up to how you write your server whether the pages
are parsed to pick the Lisp bits out of the HTML every time the
page is accessed, or only the first time the page is accessed
after being changed, or only once period using some off-line
preprocessing program [which must presumably be re-run whenever
source pages are changed!]. Different implementations have used
different strategies in the past; each has its plusses & minusses.


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607