LaravelTest
70 строк · 2.3 Кб
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4(function(mod) {5if (typeof exports == "object" && typeof module == "object") // CommonJS6mod(require("../../lib/codemirror"), require("../../addon/mode/simple"), require("../../addon/mode/multiplex"));7else if (typeof define == "function" && define.amd) // AMD8define(["../../lib/codemirror", "../../addon/mode/simple", "../../addon/mode/multiplex"], mod);9else // Plain browser env10mod(CodeMirror);11})(function(CodeMirror) {12"use strict";13
14CodeMirror.defineSimpleMode("handlebars-tags", {15start: [16{ regex: /\{\{\{/, push: "handlebars_raw", token: "tag" },17{ regex: /\{\{!--/, push: "dash_comment", token: "comment" },18{ regex: /\{\{!/, push: "comment", token: "comment" },19{ regex: /\{\{/, push: "handlebars", token: "tag" }20],21handlebars_raw: [22{ regex: /\}\}\}/, pop: true, token: "tag" },23],24handlebars: [25{ regex: /\}\}/, pop: true, token: "tag" },26
27// Double and single quotes28{ regex: /"(?:[^\\"]|\\.)*"?/, token: "string" },29{ regex: /'(?:[^\\']|\\.)*'?/, token: "string" },30
31// Handlebars keywords32{ regex: />|[#\/]([A-Za-z_]\w*)/, token: "keyword" },33{ regex: /(?:else|this)\b/, token: "keyword" },34
35// Numeral36{ regex: /\d+/i, token: "number" },37
38// Atoms like = and .39{ regex: /=|~|@|true|false/, token: "atom" },40
41// Paths42{ regex: /(?:\.\.\/)*(?:[A-Za-z_][\w\.]*)+/, token: "variable-2" }43],44dash_comment: [45{ regex: /--\}\}/, pop: true, token: "comment" },46
47// Commented code48{ regex: /./, token: "comment"}49],50comment: [51{ regex: /\}\}/, pop: true, token: "comment" },52{ regex: /./, token: "comment" }53],54meta: {55blockCommentStart: "{{--",56blockCommentEnd: "--}}"57}58});59
60CodeMirror.defineMode("handlebars", function(config, parserConfig) {61var handlebars = CodeMirror.getMode(config, "handlebars-tags");62if (!parserConfig || !parserConfig.base) return handlebars;63return CodeMirror.multiplexingMode(64CodeMirror.getMode(config, parserConfig.base),65{open: "{{", close: /\}\}\}?/, mode: handlebars, parseDelimiters: true}66);67});68
69CodeMirror.defineMIME("text/x-handlebars-template", "handlebars");70});71