API for prxml
- ()
by Stuart Sierra
Full namespace name:
clojure.contrib.prxml
Overview
Compact syntax for generating XML. See the documentation of "prxml"
for details.
Public Variables and Functions
*html-compatible*
var
If true, empty tags will have a space before the closing />
Source
*prxml-indent*
var
The number of spaces to indent sub-tags. nil for no indent
and no extra line-breaks.
Source
prxml
function
Usage: (prxml & args)
Print XML to *out*. Vectors become XML tags: the first item is the
tag name; optional second item is a map of attributes.
Sequences are processed recursively, so you can use map and other
sequence functions inside prxml.
(prxml [:p {:class "greet"} [:i "Ladies & gentlemen"]])
; => <p class="greet"><i>Ladies & gentlemen</i></p>
PSEUDO-TAGS: some keywords have special meaning:
:raw! do not XML-escape contents
:comment! create an XML comment
:decl! create an XML declaration, with attributes
:cdata! create a CDATA section
:doctype! create a DOCTYPE!
(prxml [:p [:raw! "<i>here & gone</i>"]])
; => <p><i>here & gone</i></p>
(prxml [:decl! {:version "1.1"}])
; => <?xml version="1.1" encoding="UTF-8"?>
Source