-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use bem-xjst in Node.js without bundling via browserify (#407 fixed)
- Loading branch information
1 parent
4ed06f1
commit 2984d44
Showing
3 changed files
with
49 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,15 @@ | ||
var fs = require('fs'); | ||
var Compiler = require('./lib/compiler').Compiler; | ||
var Compiler = require('./lib/compiler'); | ||
var _cache = {}; | ||
|
||
function getEngine(engineName) { | ||
if (_cache[engineName]) return _cache[engineName]; | ||
var getEngine = function getEngine(engineName) { | ||
if (_cache[engineName]) | ||
return _cache[engineName]; | ||
|
||
var runtime = require('./lib/' + engineName); | ||
var pathToBundle = require.resolve('./lib/' + engineName + '/bundle'); | ||
var sourceBundle = fs.readFileSync(pathToBundle, 'utf8'); | ||
|
||
runtime.source = sourceBundle; | ||
return _cache[engineName] = new Compiler(engineName); | ||
}; | ||
|
||
return _cache[engineName] = new Compiler(runtime); | ||
} | ||
|
||
module.exports = { | ||
get bemtree() { return getEngine('bemtree'); }, | ||
get bemhtml() { return getEngine('bemhtml'); } | ||
get bemhtml() { return getEngine('bemhtml'); }, | ||
get bemtree() { return getEngine('bemtree'); } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters