18 March 2010

Language Updates

Well, I paused working on my game to get back to working on Prog, then paused Prog again to whip up Vision, a tiny little thing for making templates for dynamic Web content—or any XML content, really. I set up both the Prog site and the Vision site using Vision, and it appears to be both handy and scalable. Here's a quick example.

Each page on the Vision site (okay, at the moment, the page on the Vision site) consists of two files: the Vision script that generates the output, and the content file giving the body text. The Vision file is very simple:

@include Page;
Page {
    "Vision Web Templating Language";

This gives the path to the Vision interpreter, includes a page template in a file called Page, and then invokes the template of the same name with some text and the contents of a file. That's it. The Page template is very simple, too, and looks like this:

@define Page (TITLE; BODY) {
    html {
        head {
            title { "Vision > "; TITLE }
            link (rel "stylesheet"; type "text/css"; href "/style.css");
        body {
            div main {
                div (class "cell") { h1 { TITLE } }
                div (class "cell") { BODY }

As you can see, the template produces an HTML document with whatever title and body content were specified. Everything else on the site is controlled by the CSS document style.css. New pages can be created quite easily by authoring a new content file and duplicating the Vision script with a reference to the new file.