CodeMirror.defineMode("mustache", function (config, parserConfig) {
	var mustacheOverlay = {
		token: function (stream, state) {
			var ch;
			if (stream.match("{{")) {
				while ((ch = stream.next()) != null)
					if (ch == "}" && stream.next() == "}") {
						stream.eat("}");
						return "mustache";
					}
			}
			while (stream.next() != null && !stream.match("{{", false)) {}
			return null;
		}
	};
	return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "text/html"), mustacheOverlay);
});

CodeMirror.defineMode("manticore", function (config) {
	return CodeMirror.multiplexingMode(
		CodeMirror.getMode(config, "shell"), {
			open: "{{",
			close: "}}",
			mode: CodeMirror.getMode(config, "mustache"),
			parseDelimiters: true
		}

	);
});