How to use bem-xjst - 10 common examples

To help you get started, we’ve selected a few bem-xjst examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bem / bem-xjst / bench / run.js View on Github external
content: fs.readFileSync(path.resolve(templatesDir, file)) + '',
    input: JSON.stringify(input)
  });
});

// node run.js --grep filter
if (argv.grep) {
  var re = new RegExp(argv.grep);
  templates = templates.filter(function(template) {
    return re.test(template.name);
  });
}

var xjst = {
  next: require('../').bemhtml,
  prev: require('bem-xjst').bemhtml
};

util._extend(benchmark.options, {
  minSamples: (argv['min-samples'] | 0) || 50,
  maxTime: (argv['max-time'] | 0) || 2
});

var suite = new benchmark.Suite();

function both(callback) {
  callback('next', xjst.next);
  if (argv.compare)
    callback('prev', xjst.prev);
}

templates.forEach(function(template) {
github vkz / bemhtml-syntax / test / common.js View on Github external
function toHtml(source, input) {
  return bemxjst.compile(ibem + source, {}).apply.call(input);
}
common.toHtml;
github bem / bem-xjst / bench / apply-stand.js View on Github external
var fs = require('fs');
var bemhtmlPrev = require('bem-xjst').bemhtml;
var bemhtmlNext = require('bem-xjst').bemhtml;
var dataPath = './node_modules/web-data/data';
var files = fs.readdirSync(dataPath);
var templatesPrev = bemhtmlPrev.compile(fs.readFileSync('./node_modules/web-data/templates.js', 'utf8'));
var templatesNext = bemhtmlNext.compile(fs.readFileSync('./node_modules/web-data/templates.js', 'utf8'));

var argv = require('yargs')
    .describe('bemjsons', 'amount of bemjsons (default 2000, max 2000)')
    .describe('repeats', 'amount of repeats test')
    .describe('verbose', 'verbose results')
    .help('h')
    .alias('help', 'h')
    .argv;

var sortNumbers = function(a, b) { return (a < b) ? -1 : 1; };

var test = function() {
github bem / bem-xjst / .enb / techs / bemxjst.js View on Github external
var xjst = require('bem-xjst');
var bemhtml = xjst.bemhtml.generate('', { exportName: 'BEMHTML' });
var bemtree = xjst.bemtree.generate('', { exportName: 'BEMTREE' });

module.exports = require('enb/lib/build-flow').create()
    .name('bemxjst')
    .target('target', '?.bemxjst.js')
    .builder(function() {
        return bemhtml
            //.replace('api.exportApply(exports);', '')
            .replace('if (typeof modules === "object") {', 'if (false && typeof modules === "object") {')
            .replace('BEMHTML = buildBemXjst(_libs)', 'BEMHTML = buildBemXjst')
            .replace('BEMHTML= buildBemXjst(glob)', 'BEMHTML = buildBemXjst')
            .concat(bemtree)
            //.replace('api.exportApply(exports);', '')
            .replace('if (typeof modules === "object") {', 'if (false && typeof modules === "object") {')
            .replace('BEMTREE = buildBemXjst(_libs)', 'BEMTREE = buildBemXjst')
            .replace('BEMTREE= buildBemXjst(glob)', 'BEMTREE = buildBemXjst')
github awinogradov / react-bl / examples / webpack.config.js View on Github external
const path = require('path');
const bemLoader = require('bem-loader');
const CollectBemAssetsPlugin = bemLoader.CollectBemAssetsPlugin;

const fs = require('fs-extra');
const bemxjst = require('bem-xjst');
const bemhtml = bemxjst.bemhtml;

const templates = bemhtml.compile([
    fs.readFileSync('./node_modules/bem-core/common.blocks/ua/ua.bemhtml'),
    fs.readFileSync('./node_modules/bem-core/common.blocks/page/page.bemhtml'),
    fs.readFileSync('./node_modules/bem-core/common.blocks/page/__js/page__js.bemhtml'),
    fs.readFileSync('./node_modules/bem-core/common.blocks/page/__css/page__css.bemhtml'),
    fs.readFileSync('./components/react/react.bemhtml.js')
].join(''));

fs.outputFile(
    './dist/index.html',
    templates.apply({
        block: 'page',
        scripts: { elem: 'js', url: './main.js' },
        content: { block: 'react' }
    })
github bem / bem-xjst / bench / apply-stand.js View on Github external
var fs = require('fs');
var bemhtmlPrev = require('bem-xjst').bemhtml;
var bemhtmlNext = require('bem-xjst').bemhtml;
var dataPath = './node_modules/web-data/data';
var files = fs.readdirSync(dataPath);
var templatesPrev = bemhtmlPrev.compile(fs.readFileSync('./node_modules/web-data/templates.js', 'utf8'));
var templatesNext = bemhtmlNext.compile(fs.readFileSync('./node_modules/web-data/templates.js', 'utf8'));

var argv = require('yargs')
    .describe('bemjsons', 'amount of bemjsons (default 2000, max 2000)')
    .describe('repeats', 'amount of repeats test')
    .describe('verbose', 'verbose results')
    .help('h')
    .alias('help', 'h')
    .argv;

var sortNumbers = function(a, b) { return (a < b) ? -1 : 1; };
github vkz / bemhtml-syntax / lib / bp.js View on Github external
match: function (json) {
        var srcjs = compat.transpile(this.src),
            compiled = bemxjst.compile(srcjs, {});
        return beautifyHtml(compiled.apply.call (json));
    }
};
github bem / bem-xjst / bench / apply-stand.js View on Github external
var fs = require('fs');
var bemhtmlPrev = require('bem-xjst').bemhtml;
var bemhtmlNext = require('bem-xjst').bemhtml;
var dataPath = './node_modules/web-data/data';
var files = fs.readdirSync(dataPath);
var templatesPrev = bemhtmlPrev.compile(fs.readFileSync('./node_modules/web-data/templates.js', 'utf8'));
var templatesNext = bemhtmlNext.compile(fs.readFileSync('./node_modules/web-data/templates.js', 'utf8'));

var argv = require('yargs')
    .describe('bemjsons', 'amount of bemjsons (default 2000, max 2000)')
    .describe('repeats', 'amount of repeats test')
    .describe('verbose', 'verbose results')
    .help('h')
    .alias('help', 'h')
    .argv;

var sortNumbers = function(a, b) { return (a < b) ? -1 : 1; };

var test = function() {
  var timesPrev = [];
  var timesNext = [];
  var res = { compile: '', applyPrev: [], applyNext: [] };
github bem / bem-xjst / bench / apply-stand.js View on Github external
var fs = require('fs');
var bemhtmlPrev = require('bem-xjst').bemhtml;
var bemhtmlNext = require('bem-xjst').bemhtml;
var dataPath = './node_modules/web-data/data';
var files = fs.readdirSync(dataPath);
var templatesPrev = bemhtmlPrev.compile(fs.readFileSync('./node_modules/web-data/templates.js', 'utf8'));
var templatesNext = bemhtmlNext.compile(fs.readFileSync('./node_modules/web-data/templates.js', 'utf8'));

var argv = require('yargs')
    .describe('bemjsons', 'amount of bemjsons (default 2000, max 2000)')
    .describe('repeats', 'amount of repeats test')
    .describe('verbose', 'verbose results')
    .help('h')
    .alias('help', 'h')
    .argv;

var sortNumbers = function(a, b) { return (a < b) ? -1 : 1; };

var test = function() {
  var timesPrev = [];
  var timesNext = [];
  var res = { compile: '', applyPrev: [], applyNext: [] };
  var times = argv.bemjsons || 2000;
github bem / bem-core / .bem / techs / bemhtml.js View on Github external
getCompiledResult : function(sources) {
        sources = sources.join('\n');

        var BEMHTML = require('bem-xjst/lib/bemhtml'),
            exportName = this.getExportName(),
            optimize = process.env[exportName + '_ENV'] !== 'development';

        return BEMHTML.generate(sources, {
            wrap : true,
            exportName : exportName,
            optimize : optimize,
            cache : optimize && process.env[exportName + '_CACHE'] === 'on'
        });
    },

bem-xjst

Declarative Template Engine for the browser and server

MPL-2.0
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis