Previous: , Up: Layouts and Rendering in GNU Artanis   [Contents]

11.6 SXML Templating

SXML is an alternative syntax for writing XML data, using the form of S-expressions.

SXML is to Scheme as JSON is to ECMAScript(the so-called Javascript). Maybe this explains clearer.

The benefit of SXML is to take advantage of quasiquote in Scheme. If you no little about it, then you may google "scheme quasiquote" for more details.

(tpl->response '(html (body (p (@ (id "content")) "hello world"))))

You would get a html string:

<html><body><p id="content">hello world</p></body></html>

Sometimes you may need quasiquote to reference a variable, for example:

(let ((content "hello world"))
  (tpl->response `(html (body (p (@ (id "content")) ,content)))))