htmlembedded.js 1.4 KB

12345678910111213141516171819202122232425262728
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: http://codemirror.net/LICENSE
  3. (function(mod) {
  4. if (typeof exports == "object" && typeof module == "object") // CommonJS
  5. mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"),
  6. require("../../addon/mode/multiplex"));
  7. else if (typeof define == "function" && define.amd) // AMD
  8. define(["../../lib/codemirror", "../htmlmixed/htmlmixed",
  9. "../../addon/mode/multiplex"], mod);
  10. else // Plain browser env
  11. mod(CodeMirror);
  12. })(function(CodeMirror) {
  13. "use strict";
  14. CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
  15. return CodeMirror.multiplexingMode(CodeMirror.getMode(config, "htmlmixed"), {
  16. open: parserConfig.open || parserConfig.scriptStartRegex || "<%",
  17. close: parserConfig.close || parserConfig.scriptEndRegex || "%>",
  18. mode: CodeMirror.getMode(config, parserConfig.scriptingModeSpec)
  19. });
  20. }, "htmlmixed");
  21. CodeMirror.defineMIME("application/x-ejs", {name: "htmlembedded", scriptingModeSpec:"javascript"});
  22. CodeMirror.defineMIME("application/x-aspx", {name: "htmlembedded", scriptingModeSpec:"text/x-csharp"});
  23. CodeMirror.defineMIME("application/x-jsp", {name: "htmlembedded", scriptingModeSpec:"text/x-java"});
  24. CodeMirror.defineMIME("application/x-erb", {name: "htmlembedded", scriptingModeSpec:"ruby"});
  25. });