Comparing version 1.0.0 to 1.1.1
20
index.js
var compile = function(file, data) { | ||
var eco = require('eco') | ||
var content = eco.compile(data) | ||
return "module.exports = " + content + ";" | ||
var result = [] | ||
result.push("var template = " + content + ";") | ||
// Allow to add hook to render, if `window.app.__render` defined it will be called | ||
// as `app.__render(template, variables)`. | ||
// It's usefull if you want to alter how template works, for example inject additional | ||
// variables. | ||
result.push("module.exports = function(variables){") | ||
result.push(" if(window.app.__render) return window.app.__render(template, variables);") | ||
result.push(" else return template(variables);") | ||
result.push("};") | ||
return result.join("\n") | ||
} | ||
@@ -15,6 +27,3 @@ | ||
if (!isEco(file)) return through(); | ||
var data = ''; | ||
return through(write, end); | ||
var data = ''; | ||
var write = function (buf) { data += buf } | ||
@@ -25,2 +34,3 @@ var end = function () { | ||
} | ||
return through(write, end); | ||
}; |
{ | ||
"name": "ecoify", | ||
"version": "1.0.0", | ||
"version": "1.1.1", | ||
"description": "browserify v2 plugin for eco templates.", | ||
@@ -5,0 +5,0 @@ "keywords": ["browserify", "eco", "template"], |
5619
103