Comparing version 0.2.0 to 0.2.1
@@ -17,2 +17,4 @@ /** | ||
* @param config.express | ||
* @param config.rootPath | ||
* @param config.cache | ||
* @param config.blocksPath | ||
@@ -28,11 +30,11 @@ * @param config.publicPath | ||
} | ||
if (!config.blocksPath){ | ||
throw new Error("blocks path is not defined for bemRender"); | ||
if (!config.rootPath){ | ||
throw new Error("root path is not defined for bemRender"); | ||
} | ||
if (!config.publicPath){ | ||
throw new Error("public path is not defined for bemRender"); | ||
} | ||
if (!config.nameRule){ | ||
config.nameRule = "%block%__%element%__%modname%-%modvalue%"; | ||
} | ||
config.cache = config.cache !== undefined ? config.cache : false; | ||
config.blocksPath = config.blocksPath || config.rootPath + "/blocks"; | ||
config.publicPath = config.publicPath || config.rootPath + "/public"; | ||
config.nameRule = config.nameRule || "%block%__%element%__%modname%-%modvalue%"; | ||
//block files are available as static files(important for the image specified in css) | ||
@@ -53,3 +55,3 @@ config.express.use("/" + path.basename(config.blocksPath), express.static(config.blocksPath)); | ||
if (jsonPath in cache && typeof cache[jsonPath] == "function"){ | ||
if (config.cache && jsonPath in cache && typeof cache[jsonPath] == "function"){ | ||
var | ||
@@ -159,2 +161,6 @@ dotFunc = cache[jsonPath], | ||
json["blockName"] = self.getCssName(isElement, parent, name); | ||
json["getBlockName"] = function(n){ | ||
return self.getCssName(isElement, parent, name + n); | ||
}; | ||
json["mods"] = json["mods"] || ""; | ||
} | ||
@@ -192,3 +198,3 @@ if (bPath in self.blocksHash) | ||
try{ | ||
indexJS.push(fs.readFileSync(js, "utf-8")); | ||
indexJS.push(fs.readFileSync(path.join(config.rootPath, js), "utf-8")); | ||
} | ||
@@ -233,3 +239,3 @@ catch(e){ | ||
addCSS.forEach(function(css){ | ||
indexLess.push('@import "' + css + '";'); | ||
indexLess.push('@import "' + path.join(config.rootPath, css) + '";'); | ||
}); | ||
@@ -236,0 +242,0 @@ for (var i in blocks){ |
{ | ||
"name": "bemrender", | ||
"description": "express.js view render based on BEM methodology", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "Ershov Konstantin <ershov.konst@gmail.com>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
12178
344