derby-jade
Advanced tools
Comparing version 0.6.13 to 0.6.14
17
index.js
@@ -86,2 +86,3 @@ var jade = require('jade'); | ||
var lastScript = Infinity; | ||
var lastElement = null; | ||
var script = []; | ||
@@ -161,2 +162,3 @@ var scripts = []; | ||
var line = lines[i]; | ||
var oldLine; | ||
var extendMatch, extendFileName, extendFile, extendTempFileName; | ||
@@ -243,3 +245,9 @@ | ||
// BEM-elements | ||
if (indent === 0) { | ||
lastElement = statement.match(/element=['"]([^'"]*)['"]/); | ||
lastElement && (lastElement = lastElement[1]) | ||
} | ||
if (indent === 0) { | ||
// Derby tag | ||
@@ -266,2 +274,11 @@ // It means that we are going to start another block, | ||
debugString += ', block'; | ||
// BEM replacement | ||
if (lastElement) { | ||
do { | ||
line = line.replace(/(^\s*[\w\.#-]*\.)(&)/, '$1' + lastElement); | ||
oldLine = line | ||
} while (line !== oldLine); | ||
} | ||
block.push(line); | ||
@@ -268,0 +285,0 @@ } |
{ | ||
"name": "derby-jade", | ||
"description": "Jade for Derby.js", | ||
"version": "0.6.13", | ||
"version": "0.6.14", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Vladimir Makhaev", |
@@ -70,2 +70,10 @@ var assert = require("assert"); | ||
it("should support BEM shorthand: compile '&' into element name of component", function() { | ||
dJade(app); | ||
var compiler = app.compilers[".jade"]; | ||
var jade = fs.readFileSync(__dirname + "/extra/bem/index.jade", "utf8"); | ||
var html = fs.readFileSync(__dirname + "/extra/bem/result.html", "utf8"); | ||
assert.equal(compiler(jade, __dirname + "/extra/bem/index.jade"), html); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27759
21
379