From 255470125db1cf0198939019dd0a8d52ec4e942a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Moreira?= Date: Wed, 23 Sep 2015 00:57:43 +0100 Subject: [PATCH] Add webpack and ect-loader basic usage example --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b569e4d..a2a8f51 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,18 @@ Blocks supports more than one level of inheritance and may be redefined. ## Client-side support +### Compiling within Webpack + +On your js file, require the template using [ect-loader](https://github.com/cusspvz/ect-loader) +```js +var body_template = require( 'ect-loader!./path/to/your/body_template.ect' ) + +document.body.innerHtml = body_template( data ) +``` +For further usage info, read more about [ect-loader](https://github.com/cusspvz/ect-loader) and [webpack](https://webpack.github.io/docs/). + +### Compiling on Browser + Download and include [coffee-script.js](https://github.com/jashkenas/coffee-script/blob/master/extras/coffee-script.js) and [ect.min.js](https://github.com/baryshev/ect/tree/master/ect.min.js). ```html @@ -212,7 +224,7 @@ var data = { title : 'Hello, World!' }; var html = renderer.render('template.ect', data); ``` -### With server side compiler middleware +#### With server side compiler middleware Download and include [ect.min.js](https://github.com/baryshev/ect/tree/master/ect.min.js). You don't need to include CoffeeScript compiler, because templates are served already compiled by server side compiler middleware.