Skip to content

dna-engine/node-jsdom-starter

Repository files navigation

node-jsdom-starter

logo

Sample dna-engine application running on node with jsdom

License:MIT Build

dna-engine.org, a UI templating library, can be run headless (no browser) on Node.js with the DOM provided by jsdom.

Setup

Execute run-app.sh.command or enter the terminal commands:

$ cd node-jsdom-starter
$ npm install
$ node app

Import and Initialize

// Imports
import { JSDOM } from 'jsdom';
import { dna } from 'dna-engine';

// Setup
const html = `
   <!doctype html>
   <html lang=en>
      <head>
         <meta charset=utf-8>
         <title>Tasks</title>
      </head>
      <body>
         <p id=task class=dna-template>~~title~~</p>
      </body>
   </html>
   `;
const dom = new JSDOM(html);
dna.initGlobal(dom.window);

Output

require dna-engine


MIT License