-
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 2ab837f
Showing
3 changed files
with
51 additions
and
61 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,18 @@ | ||
var fs = require('fs'); | ||
var Compiler = require('./lib/compiler').Compiler; | ||
var Compiler = require('./lib/compiler'); | ||
var _cache = {}; | ||
var fs = require('fs'); | ||
|
||
function getEngine(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'); | ||
var bundleSource = fs.readFileSync(pathToBundle, 'utf8'); | ||
|
||
runtime.source = sourceBundle; | ||
return _cache[engineName] = new Compiler(engineName, bundleSource); | ||
}; | ||
|
||
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