github.com/elliott5/community@v0.14.1-0.20160709191136-823126fb026a/app/public/codemirror/mode/vue/vue.js (about) 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 4 (function (mod) { 5 "use strict"; 6 if (typeof exports === "object" && typeof module === "object") {// CommonJS 7 mod(require("../../lib/codemirror"), 8 require("../../addon/mode/overlay"), 9 require("../xml/xml"), 10 require("../javascript/javascript"), 11 require("../coffeescript/coffeescript"), 12 require("../css/css"), 13 require("../sass/sass"), 14 require("../stylus/stylus"), 15 require("../jade/jade"), 16 require("../handlebars/handlebars")); 17 } else if (typeof define === "function" && define.amd) { // AMD 18 define(["../../lib/codemirror", 19 "../../addon/mode/overlay", 20 "../xml/xml", 21 "../javascript/javascript", 22 "../coffeescript/coffeescript", 23 "../css/css", 24 "../sass/sass", 25 "../stylus/stylus", 26 "../jade/jade", 27 "../handlebars/handlebars"], mod); 28 } else { // Plain browser env 29 mod(CodeMirror); 30 } 31 })(function (CodeMirror) { 32 var tagLanguages = { 33 script: [ 34 ["lang", /coffee(script)?/, "coffeescript"], 35 ["type", /^(?:text|application)\/(?:x-)?coffee(?:script)?$/, "coffeescript"] 36 ], 37 style: [ 38 ["lang", /^stylus$/i, "stylus"], 39 ["lang", /^sass$/i, "sass"], 40 ["type", /^(text\/)?(x-)?styl(us)?$/i, "stylus"], 41 ["type", /^text\/sass/i, "sass"] 42 ], 43 template: [ 44 ["lang", /^vue-template$/i, "vue"], 45 ["lang", /^jade$/i, "jade"], 46 ["lang", /^handlebars$/i, "handlebars"], 47 ["type", /^(text\/)?(x-)?jade$/i, "jade"], 48 ["type", /^text\/x-handlebars-template$/i, "handlebars"], 49 [null, null, "vue-template"] 50 ] 51 }; 52 53 CodeMirror.defineMode("vue-template", function (config, parserConfig) { 54 var mustacheOverlay = { 55 token: function (stream) { 56 if (stream.match(/^\{\{.*?\}\}/)) return "meta mustache"; 57 while (stream.next() && !stream.match("{{", false)) {} 58 return null; 59 } 60 }; 61 return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "text/html"), mustacheOverlay); 62 }); 63 64 CodeMirror.defineMode("vue", function (config) { 65 return CodeMirror.getMode(config, {name: "htmlmixed", tags: tagLanguages}); 66 }, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "jade", "handlebars"); 67 68 CodeMirror.defineMIME("script/x-vue", "vue"); 69 });