Created
November 14, 2011 16:58
-
-
Save lukemorton/1364437 to your computer and use it in GitHub Desktop.
CodeMirror mustache support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CodeMirror.defineMode("mustache", function (config, parserConfig) { | |
var mustacheOverlay = { | |
token: function (stream, state) { | |
if (stream.match("{{")) { | |
while ((ch = stream.next()) != null) | |
if (ch == "}" && stream.next() == "}") break; | |
return "mustache"; | |
} | |
while (stream.next() != null && !stream.match("{{", false)) {} | |
return null; | |
} | |
}; | |
return CodeMirror.overlayParser(CodeMirror.getMode(config, parserConfig.backdrop || "text/html"), | |
mustacheOverlay); | |
}); | |
//Credit unknown :( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to upgrade some an old CodeMirror code mode and comparing this with the newer version that @peterflynn posted of mustache helped me solve the issue I was having (
overlayParser
is nowoverlayMode
). Thank you both!