A clever compiler for BEM-specific templates with JavaScript syntax.

Install it by npm: npm install bem-xjst.

var bem = require('bem-xjst');
var template = bem.compile('... your source code ...');
template.apply(/* ... your input data here ... */);
// Or even better: 
template = bem.compile(function() {
template.apply({ block: 'b1' });
$ bem-xjst --help
  bem-xjst [OPTIONS] [ARGS]
  -h, --help : Help
  -v, --version : Version
  -d, --dev-mode : Dev mode
  -i INPUT, --input=INPUT : Input file (default: stdin)
  -o OUTPUT, --output=OUTPUT : Output file (default: stdout)

Compile input templates and return templates object. (See documentation below for its methods)

Generate output JavaScript code that might be transferred and executed in browser to get the templates object.

Run compiled templates on specified input context. Return resulting HTML output.

Add more BEM templates to the templates instance. Might be called in runtime to deliver more blocks declarations to the client.

Constructor of the this object available in template bodies. Might be amended to expose some functionality to the templates, or to add _flush method.

To run benchmarks:

cd benchmarks/
npm install
node run.js -h
node run.js

Benchmarks could be run in --compare mode to verify abscence of regressionfccd9d4s in comparison to previous bem-xjst verison. Make sure that the benchmarks/package.json has the right git hash of bem-xjst before running!

See wiki

Code and documentation copyright 2015 YANDEX LLC. Code released under the Mozilla Public License 2.0.