javascript (and jquery) templating

I just put up some code for doing templating with javascript(and jquery). Either on the server side or on the client side. If you open the html in your browser, it runs on the client side. If you first process it server side... then it runs server side(but not on the client side).

http://github.com/illume/nodejs_jquery_templating

This is a followup from you are using the wrong templating language - as a proof of concept.

Why is this useful?

  • No need for a server to process the templates. Either process them server side or client side.
  • Data can be stored in a json file. No need for a database for testing. Just create json files in a text file.
  • Can reuse knowledge of javascript libraries (like jquery), rather than learning one of 798394 different templating languages.
  • Can keep one html file which front end web developers can edit without them needing a new template file.
  • Can use jquery plugins on server side too(validation, etc).

Seems to work ok so far... but it still needs a lot of polish before it'll be useful. If it works out ok, I'll try it out on some real projects (where the main server side language is python).

Comments

Anonymous said…
Impressive work, haven't checked out the code yet (but will clone it later)... Q: How does the server-side process the templates ? What do you need server-side (per say) ?
René Dudfield said…
Hi,

it currently uses the nodejs server nodejs.org - which uses the v8 javascript implementation.

It should be easy enough to use various other javascript implementations though.
Anonymous said…
Wow quick response :) You must be checking blog comments every few mins or have instant notifications!

Yeah I was wondering about that... nodejs seems to be picking up quite a bit of popularity (I guess because of the same language server-side and client-side aspect). I was going to try out your code with my python web framework circuits.web (see my bb projects).

--James
René Dudfield said…
hi ya,

yeah I get an email when someone comments... so I can delete spam and read comments in my email.

Note the code is a bit ugly, and buggy at the moment... so not for production but still fun to play with :)

If you have any questions about it or nodejs etc please let me know. I tried to add a little documentation in there to make it easier to play with.

Now to try and clean it up enough to use in a real project...

cya.

Popular posts from this blog

Draft 3 of, ^Let's write a unit test!^

Is PostgreSQL good enough?

post modern C tooling - draft 6