bem-sdk-archive / bem-decl

:capital_abcd: Manage declaration of BEM entities. DEPRECATED →
https://github.com/bem/bem-sdk/tree/master/packages/decl
Other
11 stars 3 forks source link

Implement `parse` method to parse data in files #33

Closed qfox closed 8 years ago

qfox commented 8 years ago

Ref: #6

Methods:

The method should determine the format of the file content.

BEMDECL 1.0

exports.blocks = [
    { name: 'block' }
];

or

exports.version = '1.0';
exports.decl = [
    { name: 'block' }
];

BEMDECL 2.0

exports.version = '2.0';
exports.decl = [
    { block: 'block' }
];

BEMDECL next

exports.version = 'next';
exports.decl = [
    { block: 'block' }
];

The method should translate any format to normalized BEMDECL 2.0.

var parse = require('bem-decl').parse;

// bemdecl-1.0.js
// exports.blocks = [
//     { name: 'block' }
// ];

parse(fs.readFileSync('bemdecl-1.0.js')); // [{ block: 'block' }]
qfox commented 8 years ago

Prbbly parse isn't the best name for this method. Any other suggestions?