Just wanted to ping the list and let everyone know a more mature of version
of xml-literals is available to install if anyone is interested in checking
it out. I sent out my work to the Node list more than a year ago, but
didn't bother making it too accessible to the greater community. C++ and
boost were required and it wasn't even in npm so it was pretty hard to work
with, but that's no longer true! In that time I've been using xml-literals
in my own project working out bugs as I found them.

Basically xml-literals gives you a safe and easy way to generate XML (or
HTML) documents. For example:

var name = uri.query.name;
var greeting = <p>Hello, {name}. Good to meet you.</p>;
response.write(greeting.toString());

XML literals can span multiple lines and you can insert arbitrary data via
JS expressions in {}'s.

If you're familiar with E4X (put down your pitchforks!) you could consider
it "E4X: The Good Parts". Or if you've heard of Facebook's XHP you could
consider it XHP for JS.

Advantages:
- Context-sensitive escaping, no XSS
- Easy to write, directly represents what will be sent to the browser, no
quotes and +'s required
- Functional decomposition is a breeze with document fragments and DOM
manipulation (appendChild, insertBefore, etc)
- Can be applied to client-side JS, directly creating DOM nodes

Disadvantages:
- "Not Javascript"
- Relies on code transformation
- Your text editor might freak out (vim does fine unless you use quotes or
apostrophes in raw html)

A full example w/ http server can be found here:
https://raw.github.com/laverdet/js-xml-literal/master/example/main.js

Install with:
npm install xml-literals

github:
https://github.com/laverdet/js-xml-literal

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to