Skip to content

Instantly share code, notes, and snippets.

@funkytaco
Forked from tmpvar/node-jsdom-pure.js
Created July 16, 2013 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funkytaco/6015590 to your computer and use it in GitHub Desktop.
Save funkytaco/6015590 to your computer and use it in GitHub Desktop.
tmpmac:javascript tmpvar$ node node-jsdom-pure.js
<div id="template">
<div class="hello">
<span class="who">Hello Wrrrld</span>
</div>
</div>
var doc = require("jsdom").jsdom(),
window = doc.createWindow(),
jQueryElement = doc.createElement("script"),
pureElement = doc.createElement("script"),
body = doc.getElementsByTagName("body").item(0),
directive = { "span.who": "who" },
data = { "who": "Hello Wrrrld" };
body.innerHTML = '<div id="template"><div class="hello">\
<span class="who"></span>\
</div></div>';
// Load up jQuery
jQueryElement.src = "http://code.jquery.com/jquery-1.4.4.js"
doc.head.appendChild(jQueryElement);
// Load up PURE
pureElement.src = "http://beebole.com/pure/wp-content/themes/BeeBole-pure/libs/pure.js";
doc.head.appendChild(pureElement);
pureElement.onload = function() {
window.jQuery('div#template').render(data, directive);
console.log(body.innerHTML);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment