Commit | Line | Data |
---|---|---|
44f4c339 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
373d1232 | 2 | // Distributed under an MIT license: https://codemirror.net/LICENSE |
44f4c339 | 3 | |
837afb80 TD |
4 | (function(mod) { |
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS | |
44f4c339 AE |
6 | mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), |
7 | require("../../addon/mode/multiplex")); | |
837afb80 | 8 | else if (typeof define == "function" && define.amd) // AMD |
44f4c339 AE |
9 | define(["../../lib/codemirror", "../htmlmixed/htmlmixed", |
10 | "../../addon/mode/multiplex"], mod); | |
837afb80 TD |
11 | else // Plain browser env |
12 | mod(CodeMirror); | |
13 | })(function(CodeMirror) { | |
44f4c339 AE |
14 | "use strict"; |
15 | ||
16 | CodeMirror.defineMode("htmlembedded", function(config, parserConfig) { | |
373d1232 | 17 | var closeComment = parserConfig.closeComment || "--%>" |
44f4c339 | 18 | return CodeMirror.multiplexingMode(CodeMirror.getMode(config, "htmlmixed"), { |
373d1232 TD |
19 | open: parserConfig.openComment || "<%--", |
20 | close: closeComment, | |
21 | delimStyle: "comment", | |
22 | mode: {token: function(stream) { | |
23 | stream.skipTo(closeComment) || stream.skipToEnd() | |
24 | return "comment" | |
25 | }} | |
26 | }, { | |
44f4c339 AE |
27 | open: parserConfig.open || parserConfig.scriptStartRegex || "<%", |
28 | close: parserConfig.close || parserConfig.scriptEndRegex || "%>", | |
29 | mode: CodeMirror.getMode(config, parserConfig.scriptingModeSpec) | |
30 | }); | |
31 | }, "htmlmixed"); | |
32 | ||
33 | CodeMirror.defineMIME("application/x-ejs", {name: "htmlembedded", scriptingModeSpec:"javascript"}); | |
34 | CodeMirror.defineMIME("application/x-aspx", {name: "htmlembedded", scriptingModeSpec:"text/x-csharp"}); | |
35 | CodeMirror.defineMIME("application/x-jsp", {name: "htmlembedded", scriptingModeSpec:"text/x-java"}); | |
36 | CodeMirror.defineMIME("application/x-erb", {name: "htmlembedded", scriptingModeSpec:"ruby"}); | |
837afb80 | 37 | }); |