This repository has been archived by the owner on Aug 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from bem-sdk/yeti-or.bem-cell
Add support for @bem/cell
- Loading branch information
Showing
5 changed files
with
242 additions
and
73 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
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,10 +1,25 @@ | ||
var bemNaming = require('bem-naming'); | ||
var path = require('path'), | ||
assert = require('assert'), | ||
BemCell = require('@bem/cell'), | ||
bemNaming = require('bem-naming'); | ||
|
||
module.exports = { | ||
path: function(entity, tech, options) { | ||
path: function(cell, options) { | ||
assert(BemCell.isBemCell(cell), | ||
'Provide instance of [@bem/cell](https://github.com/bem-sdk/bem-cell).' | ||
) | ||
|
||
options || (options = {}); | ||
|
||
var layer = ''; | ||
var tech = cell.tech; | ||
var entity = cell.entity; | ||
|
||
cell.layer && (layer = cell.layer); | ||
|
||
var naming = bemNaming(options.naming); | ||
|
||
return naming.stringify(entity) + '.' + tech; | ||
return path.join(layer, | ||
naming.stringify(entity) + (tech ? '.' + tech : '')); | ||
} | ||
}; |
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,17 +1,29 @@ | ||
var path = require('path'), | ||
assert = require('assert'), | ||
BemCell = require('@bem/cell'), | ||
bemNaming = require('bem-naming'); | ||
|
||
module.exports = { | ||
path: function(entity, tech, options) { | ||
path: function(cell, options) { | ||
assert(BemCell.isBemCell(cell), | ||
'Provide instance of [@bem/cell](https://github.com/bem-sdk/bem-cell).' | ||
) | ||
|
||
options || (options = {}); | ||
var naming = bemNaming(options.naming), | ||
elemFolder = naming.elemDelim + entity.elem, | ||
modFolder = naming.modDelim + entity.modName, | ||
folder = path.join(entity.block, | ||
entity.elem ? elemFolder : '', | ||
entity.modName ? modFolder : ''); | ||
|
||
var layer = ''; | ||
var tech = cell.tech; | ||
var entity = cell.entity; | ||
var modName = Object(entity.mod).name; | ||
|
||
cell.layer && (layer = cell.layer); | ||
|
||
var naming = bemNaming(options.naming); | ||
var folder = path.join(layer, entity.block, | ||
entity.elem ? (naming.elemDelim + entity.elem) : '', | ||
modName ? (naming.modDelim + modName) : ''); | ||
|
||
return path.join(folder, | ||
naming.stringify(entity) + '.' + tech); | ||
naming.stringify(entity) + (tech ? '.' + tech : '')); | ||
} | ||
}; |
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
Oops, something went wrong.