示例#1
0
module.exports = function (path, options) {
    var parts = path;
    var naming = new BEMNaming(options);

    function id() {
        return naming.stringify(this);
    }

    if (typeof path === 'string') {
        parts = naming.parse(basename(path));
        if (!parts) { throw new Error('Could not parse "' + path + '"'); }
        parts.level = dirname(path);
    }

    var bem = new BEMObject(parts);

    Object.defineProperties(bem, {
        id: {
            get: id,
            enumerable: true
        },
        bem: {
            get: id,
            enumerable: true
        }
    });

    return bem;
};
示例#2
0
 function id() {
     return naming.stringify(this);
 }