Posts

Showing posts with the label templates

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...

You are using the wrong #templating system for #html.

Use javascript + json + DOM for html templating. Front end developers know how to use this technology. They know this technology very well, so will be way productive. No weird new template language to learn and install on every single project. No dependency on a rapidly changing server side backend... or database, or 3rd party API required. No taking the html, and turning it into [$%%WEIRD TEMPLATE LANG%%$$] step. Instead you can use javascript, json and the DOM. Being able to use the templating system either via the browser, or via the server side means there is no dependency between the front end and the back end. Front end developers just need an example json file to work from. Then the back end developer just needs to create the json file. It does mean you are dependent on a DOM+javascript implementation on the server side if you want to do things like server side caching, and supporting Agents(browsers, bots etc) that do not use javascript on the client side. Just json files....

Genshi templates - header/footer templates, and including templates.

Image
How to include a Genshi template inside of another genshi template? Use "py:match" inside the template you want to include into other pages (eg. a sitelayout.html). Then you can use "xi:include" in the pages you want the files included in. (eg. best_picture_of_my_cat_today.html) Now, it's not a "simple include this template here" kind of thing. The py:match can find various parts of the file, and then replace them how they like. For example, a page layout template will match the header and footer with "py:match". It is best explained with examples, and in the documentation: pylons genshi example Includes section of the genshi documentation where it explains "xi:include". Genshi documentation where it explains py:match . Hopefully this explains the genshi way of including a template into a template.

javascript for templates - it's happening.

It seems like javascript for template languages might be the way forward. designer friendly. lots of web designers know a little javascript or actionscript. can run in a browser. javascript can be sandboxed. most web developers know a little js too. Web developers that don't know javascript will most likely at know at least a little C/php/perl/java to be able to do a lot of things with javascript. Tenjin allows javascript templates. It also allows many other scripting languages to be used in templates... but that's not really what I'm talking about. Fast, small(200k), opensource and widely deployed javascript/emca script interpreters exist. Tamarin is a emca JIT optimized virtual machine from flash 9, that mozilla is using in upcoming versions of firefox. There is also spidermonkey - the current firefox javascript implementation. Finally there is haxe , which is a emca script like language - that can output .js files, flash swf files, and also neko which runs as a ...