regex cleanup; fixed indenting on partials

This commit is contained in:
psychobunny
2014-03-05 15:58:43 -05:00
parent 67517c58e3
commit 3efca794fd

View File

@@ -103,14 +103,15 @@ function compileTemplates() {
async.each(Object.keys(paths), function(relative_path, next) {
var file = fs.readFileSync(paths[relative_path]).toString(),
matches = null;
matches = null,
regex = /[ \t]*<!-- IMPORT ([\s\S]*?)? -->[ \t]*/;
while (matches = file.match(/<!-- IMPORT ([\s\S]*?)? -->/)) {
while (matches = file.match(regex)) {
if (paths["/" + matches[1]]) {
file = file.replace(/<!-- IMPORT ([\s\S]*?)? -->/, fs.readFileSync(paths["/" + matches[1]]).toString());
file = file.replace(regex, fs.readFileSync(paths["/" + matches[1]]).toString());
} else {
winston.warn('[themes] Partial not found: ' + matches[1]);
file = file.replace(/<!-- IMPORT ([\s\S]*?)? -->/, "");
file = file.replace(regex, "");
}
}