Sunday April 14, 2013

Nu now includes built in operators for generating HTML and other XML-style markup.

For usage examples, see the test/ unit tests.

As a simple example, this Nu code:

(puts (&html (&body (&h1 "Hello!")
                    (&p "This is a test")
                    (&p "This is a second paragraph"))))

produces the following output:

<!DOCTYPE html><html><body><h1>Hello!</h1><p>This is a test</p><p>This is a second paragraph</p></body></html>

You'll note that no line breaks or formatting is included. These can easily be added with xmllint:

%nush | xmllint --format -
<?xml version="1.0"?>
<!DOCTYPE html>
    <p>This is a test</p>
    <p>This is a second paragraph</p>

Also, the Nu source formatter (in now produces prettier output.

Download Nu here.