Comparing version 1.0.1 to 1.0.2
@@ -6,3 +6,4 @@ var ometajs = require('ometajs'), | ||
BEMCParser = bemc.BEMCParser, | ||
BEMCToXJST = bemc.BEMCToXJST; | ||
BEMCToXJST = bemc.BEMCToXJST, | ||
BEMCLogLocal = bemc.BEMCLogLocal; | ||
@@ -19,3 +20,12 @@ // | ||
var tree = BEMCParser.matchAll(source, 'topLevel'), | ||
xjstTree = xjst.translate(BEMCToXJST.match(tree, 'topLevel')), | ||
xjstPre = BEMCToXJST.match(tree, 'topLevel'), | ||
vars = []; | ||
if (options.cache === true) { | ||
var xjstCached = BEMCLogLocal.match(xjstPre, 'topLevel'); | ||
vars = xjstCached[0]; | ||
xjstPre = xjstCached[1]; | ||
} | ||
var xjstTree = xjst.translate(xjstPre), | ||
exportName = options.exportName || 'TEMPLATES', | ||
@@ -30,10 +40,16 @@ xjstOpts = options.devMode? { 'no-opt': true } : { engine: 'sort-group' }; | ||
return 'var ' + exportName + ' = ' + xjstJS + ';\n' + | ||
exportName + ' = (function(xjst) {\n' + | ||
' return function() {\n' + | ||
' return xjst.apply.call(\n' + | ||
(options.raw ? 'this' : '[this]') + '\n' + | ||
' ); };\n' + | ||
'}(' + exportName + '));\n' + | ||
'typeof exports === "undefined" || (exports.' + exportName + ' = ' + exportName + ');'; | ||
return 'var ' + exportName + ' = function() {\n' + | ||
' var cache,\n' + | ||
' xjst = ' + xjstJS + ';\n' + | ||
' return function(options) {\n' + | ||
' if (!options) options = {};\n' + | ||
' cache = options.cache;\n' + | ||
(vars.length > 0 ? ' var ' + vars.join(', ') + ';\n' : '') + | ||
' return xjst.apply.call(\n' + | ||
(options.raw ? 'this' : '[this]') + '\n' + | ||
' );\n' + | ||
' };\n' + | ||
'}();\n' + | ||
'typeof exports === "undefined" || ' + | ||
'(exports.' + exportName + ' = ' + exportName + ');'; | ||
}; | ||
@@ -40,0 +56,0 @@ |
{ | ||
"name": "bemc", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"homepage": "http://github.com/bem/bemc", | ||
@@ -19,4 +19,4 @@ "author": "Fedor Indutny <fedor.indutny@gmail.com> (http://github.com/indutny)", | ||
"coa": "*", | ||
"xjst": "~0.3.3", | ||
"ometajs": "~3.1.4", | ||
"xjst": "~0.3.16", | ||
"ometajs": "~3.1.17", | ||
"q-fs": "~0.1.33" | ||
@@ -23,0 +23,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22813
189
1
Updatedometajs@~3.1.17
Updatedxjst@~0.3.16