class Spah.DOM.Blueprint
Description
A “blueprint” is a server-side representation of your application’s layout. Blueprints are used during Spah’s cold-rendering cycle, when a user is requesting a page via a regular non-ajax HTTP request. A Blueprint contains all the markup for your app, annotated with SpahQL assertions. Whenever the blueprint is served to a user, the document logic is run, the document set into precisely the state needed to display the relevant UI state to the user and the resulting HTML shipped down the wire to the browser, from whence the Spah client will take over for all future requests.
Blueprints are compiled from some source HTML, which will be your app’s markup with included document logic, and after the compile step you may add additional customisations by adding resources such as templates and rulesets.
Let’s look at an example, with comments:
var blueprint = require(‘spah’).dom.blueprint; // Prepare your markup. Read it from the file system, get it from a database, whatever. // We want to end up with a String, not a Buffer. var html = “<!DOCTYPE HTML>
........”; // Now we’ll compile the blueprint blueprint.compile(html, function(err, myBlueprint) { // Handle errors if(err) return console.log(“ERROR!”, err); // Move on with processing})