0.2.1 • Published 11 years ago
sejs v0.2.1
sEJS

Embedded JavaScript templates without the bells and whistles.
Why
sEJS spun out of an endeavor to understand how JavaScript templating (in the vein of ERB or PHP) works. It is:
A smaller EJS.
Similar to John Resig’s micro-templating script, but without regular expressions and with better error reporting.
Usage
var tmpl = '<% if (foo) { %>' +
'<%= foo.bar %>, <%= foo.baz %>!' +
'<% } %>';
var data = {
foo: {
bar: 'Hello',
baz: 'World'
}
};
sejs(tmpl)(data); //=> 'Hello, World!'Place JavaScript between <% and %> tags. To print a variable, use <%= for the opening tag.
API
sejs(tmpl)(data)
Returns a String, the result of rendering tmpl using values from data.
tmpl— The template String.data— An Object literal of values.
Installation
Install via npm:
$ npm i --save sejsInstall via bower:
$ bower i --save yuanqing/sejsTo use sEJS in the browser, include the minified script in your HTML:
<body>
<!-- ... -->
<script src="path/to/sejs.min.js"></script>
<script>
// sejs available here
</script>
</body>Changelog
- 0.2.0
sejs(tmpl)(data)replacessejs.render(tmpl, data)- Remove
sejs.renderFile(tmplFile, data, cb) - Add bower.json
- Add a minified version of the module
- 0.1.0
- Initial release