var gutil = require('gulp-util');
var PluginError = gutil.PluginError;
var through = require('through');

function pluginError (message) {
  return new PluginError('gulp-jade-template-concat', message);
}

module.exports = function jadeConcat(fileName, _opts) {

  if (!fileName) {
    throw pluginError('Missing filename');
  }

  var concatString = "";
  var templateVariable = _opts.templateVariable || 'templates';

  function write (file) {

    if (file.isNull()) {
      return;
    }

    if (file.isStream()) {
      return this.emit('error', pluginError('Streaming not supported'));
    }

    //isolate filename from full path
    var filename = file.path.replace(file.base, "").replace(".js", "");

    // replace template name with filename
    var contents = file.contents.toString().replace('function template', '"' + filename + '": function');

    concatString += contents + ",\n";
  }

  function end () {

    //wrap concatenated string in template object
    var templateString = "var " + templateVariable + " = {\n" + concatString + "}";

    this.queue(new gutil.File({
      path: fileName,
      contents: new Buffer(templateString)
    }))

    this.queue(null);
  }

  return through(write, end);
}

@@ -663,49 +663,184 @@
 path
-.replace(file.base, %22%22).replace(%22.js%22, %22%22
+%0A                       .replace(file.base, %22%22)%0A                       .replace(%22.js%22, %22%22)%0A                       .replace('%5C%5C', '--')%0A                       .replace('/', '--'
 );%0A%0A

Replace \\ to -- on windows and / to -- on linux