https://github.com/open-node/ecofy
https://github.com/open-node/ecofy
coffee ejs template
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/open-node/ecofy
- Owner: open-node
- Created: 2014-06-16T05:32:42.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-06-16T05:41:36.000Z (over 11 years ago)
- Last Synced: 2024-10-29T18:10:48.747Z (about 1 year ago)
- Topics: coffee, ejs, template
- Language: JavaScript
- Size: 121 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ecofy
[eco][] precompiler plugin for [Browserify][] without magic.
Compiles Handlebars templates to plain Javascript. The compiled templates only
have one copy of the Handlebars runtime so they are lightweight and fast!
## Usage
Install hbsfy locally to your project:
npm install ecofy
Handlebars will be automatically installed as [peer dependency][].
Then use it as Browserify transform module with `-t`:
browserify -t eco main.js > bundle.js
where main.js can be like:
```javascript
var template = require("./template.eco");
document.body.innerHTML = template({ name: "Epeli" });
```
and template.hbs:
```html
Hello <%=name%>!
```
## Programmatic usage
When compiling using Javascript code custom extensions
can be set:
```javascript
var ecofy = require("ecofy");
var browserify = require("browserify");
var b = browserify("./index.js");
b.transform(ecofy);
b.bundle().pipe(fs.createWriteStream("./bundle.js"));
```
[eco]: https://github.com/sstephenson/eco
[Browserify]: https://github.com/substack/node-browserify