Created
June 7, 2014 08:37
-
-
Save melbourne2991/7ae4f840b4b89b5699fc to your computer and use it in GitHub Desktop.
bad prototypal usage.
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
var fs = require('fs'); | |
var _ = require('lodash'); | |
var cheerio = require('cheerio'); | |
module.exports = {}; | |
module.exports.build = {}; | |
module.exports.build.template = {}; | |
modulesPath = __dirname + '/../../modules/' | |
var parsedElement = function(i) { | |
this.elementName = null; | |
this.className = null; | |
this.element = null; | |
if(this.setElementName(i)) | |
return true | |
} | |
parsedElement.prototype.setElementName = function(i) { | |
var sliced = [i.slice(0, 1), i.slice(1, i.length)]; | |
if(sliced[0] === '_') { | |
this.className = sliced[1]; | |
} else { | |
this.elementName = i; | |
} | |
} | |
console.log(parsed_element); | |
var parseElements = function(element, i) { | |
// Underscore represents a class | |
if(i && parseElementName.isClass(i)) { | |
console.log(i + ' has underscore'); | |
} else if(i) { | |
console.log(i + ' has no underscore'); | |
} | |
if(element['elements']) { | |
_.forEach(element['elements'], function(element, i) { | |
parseElements(element, i); | |
}); | |
} | |
}; | |
module.exports.build.module = function(args) { | |
var path = modulesPath + args[0] + '/blueprint.js'; | |
fs.open(path, 'r', function(err, fs) { | |
if(err && err.errno !== 34) { | |
throw err; | |
} else if(err) { | |
var err = new Error('Could not find module blueprint') | |
throw err; | |
} | |
var blueprint = require(path); | |
// Build CSS | |
_.forEach(blueprint.elements, function(parent_elements, i) { | |
// Load cheerio | |
// if(isClass(i)) { | |
// $ = cheerio.load('<div class') | |
// } | |
parseElements(parent_elements); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment