Skip to content
This repository has been archived by the owner on Aug 1, 2019. It is now read-only.

Commit

Permalink
MAJOR
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeti-or committed Jan 24, 2017
1 parent 9df0c17 commit 671b420
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 146 deletions.
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@

## Usage
```js
var entity = {
block: 'b1',
elem: 'e1',
modName: 'm1',
modVal: 'v1'
};

var tech = 'js';
var BemCell = require('@bem/cell'),
BemEntityName = require('@bem/entity-name');

var atom = new BemCell(
{
entity: new BemEntityName({
block: 'b1',
elem: 'e1',
mod: {name: 'm1', val: 'v1'}
}),
tech: 'js'
}
);

var options = {
naming: {
Expand All @@ -25,7 +30,9 @@ var options = {
}
}; // this is default value

require('bem-fs-scheme')('nested').path(entity, tech, options); // b1/__e1/_m1/b1__e1_m1_v1.js
var bemFs = require('bem-fs-scheme')('nested')

bemFs.path(atom, options); // b1/__e1/_m1/b1__e1_m1_v1.js
```

License
Expand Down
17 changes: 5 additions & 12 deletions lib/schemes/flat.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
var path = require('path'),
BemCell = require('@bem/cell'),
bemNaming = require('bem-naming');

module.exports = {
path: function(entity, tech, options) {
path: function(cell, options) {
options || (options = {});

var layer = '';
var _tech = tech;
var tech = cell.tech;
var entity = cell.entity;

if (BemCell.isBemCell(entity)) {
entity.layer && (layer = entity.layer);
if (typeof tech === 'object') {
options = tech;
}
_tech = entity.tech;
entity = entity.entity;
}
cell.layer && (layer = cell.layer);

var naming = bemNaming(options.naming);

return path.join(layer,
naming.stringify(entity) + (_tech ? '.' + _tech : ''));
naming.stringify(entity) + (tech ? '.' + tech : ''));
}
};
22 changes: 6 additions & 16 deletions lib/schemes/nested.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
var path = require('path'),
BemCell = require('@bem/cell'),
bemNaming = require('bem-naming');

module.exports = {
path: function(entity, tech, options) {
path: function(cell, options) {
options || (options = {});

var layer = '';
var modName = '';
var _tech = tech;
var tech = cell.tech;
var entity = cell.entity;
var modName = Object(entity.mod).name;

if (BemCell.isBemCell(entity)) {
entity.layer && (layer = entity.layer);
if (typeof tech === 'object') {
options = tech;
}
_tech = entity.tech;
entity = entity.entity;
modName = Object(entity.mod).name;
} else {
modName = entity.modName;
}
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 ? '.' + _tech : ''));
naming.stringify(entity) + (tech ? '.' + tech : ''));
}
};
Loading

0 comments on commit 671b420

Please sign in to comment.