_
(_)___ _________ ______ _____
/ / __ `/ ___/ _ \/ ___/ | / / _ \
/ / /_/ (__ ) __/ / | |/ / __/
__/ /\__, /____/\___/_/ |___/\___/
/___/ /_/
h1. jqserve
Use jqserve to serve files after running them through whatever jQuery code you desire. You'll won't have to think about templating languages, and your designer won't need to fire up a dev server in order to write html and css!
Here's how to make it serve a file from your ./public
folder using after modifying it with $('
').text('hey dude').appendTo('body')
:
jqserve(request, response, 'index.html', function(err, $){
$('').text('hey dude').appendTo('body');
});
The request and response objects used as arguments are the generic ones from "http.createServer":http://nodejs.org/api.html#http-server-158.
Here's how to make it serve a file from your ./public
folder using node-static:
jqserve(request, response, 'index.html');
Note: If it cannot serve the desired file, it will attempt to serve ./public/404.html
. At the moment, it will crash if this file does not exist when it tries to serve it.
h2. Demo
Note: this is probably not ready for production.
Here's how to run the demo:
git clone git@github.com:DTrejo/jqserve.git
cd jqserve
node server.js
Then visit "localhost:8080":http://localhost:8080 and "localhost:8080/index.html":http://localhost:8080/index.html, and compare the differences.
h2. Performance
It seems that running jquery code against a file before serving it is 2 magnitudes slower than serving it from node-static. Oopsie.