Created
December 5, 2010 20:24
-
-
Save tmpvar/729432 to your computer and use it in GitHub Desktop.
basic example for getting node + jsdom + pure.js going
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tmpmac:javascript tmpvar$ node node-jsdom-pure.js | |
<div id="template"> | |
<div class="hello"> | |
<span class="who">Hello Wrrrld</span> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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