gulp-bem / gulp-bem-xjst

DEPRECATED repository, moved to https://github.com/bem/gulp-bem/tree/master/packages/gulp-bem-xjst
MIT License
6 stars 3 forks source link

Add context option #56

Open blond opened 8 years ago

blond commented 8 years ago

To build i18n with bem-core need provide code of i18n core to BEMContext.

Example:

const gulp = require('gulp');
const bemhtml = require('gulp-bem-xjst').bemhtml;
const I18NCode = readFileSync('path/to/core');

gulp.task('default', function () {
    return gulp.src('page.bemhtml')
        .pipe(bemhtml({
            context: { i18n: I18NCode }
        }))
        .pipe(gulp.dest('dist'));
});

This code should add BEM-XJST template to sources:

oninit(function(exports, context) {
    var BEMContext = exports.BEMContext || context.BEMContext;
    BEMContext.prototype.i18n = I18NCode;
});