Client side

1. Download and include coffee-script.js and ect.min.js.

<script src="/path/coffee-script.js"></script> <script src="/path/ect.min.js"></script>

2. Use it.

var renderer = ECT({ root : '/views' }); var data = { title : 'Hello, World!' }; var html = renderer.render('template.ect', data);

With server side compiler middleware

1. Download and include ect.min.js. You don't need to include CoffeeScript compiler, because templates are served already compiled by server side compiler middleware.

<script src="/path/ect.min.js"></script>

2. Setup server side compiler middleware.

var connect = require('connect'); var ECT = require('ect'); var renderer = ECT({ root : __dirname + '/views', ext : '.ect' }); var app = connect() .use(renderer.compiler({ root: '/views', gzip: true })) .use(function(err, req, res, next) { res.end(err.message); }); app.listen(3000);

3. Use it.

var renderer = ECT({ root : '/views', ext : '.ect' }); var data = { title : 'Hello, World!' }; var html = renderer.render('template', data);

Note: root folder must be on the same domain to avoid cross-domain restrictions.