Subversion-Projekte lars-tiefland.ci

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
776 lars 1
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2
// Distributed under an MIT license: http://codemirror.net/LICENSE
3
 
4
(function(mod) {
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
6
    mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
7
  else if (typeof define == "function" && define.amd) // AMD
8
    define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
9
  else // Plain browser env
10
    mod(CodeMirror);
11
})(function(CodeMirror) {
12
  "use strict";
13
 
14
  CodeMirror.defineSimpleMode("handlebars", {
15
    start: [
16
      { regex: /\{\{!--/, push: "dash_comment", token: "comment" },
17
      { regex: /\{\{!/,   push: "comment", token: "comment" },
18
      { regex: /\{\{/,    push: "handlebars", token: "tag" }
19
    ],
20
    handlebars: [
21
      { regex: /\}\}/, pop: true, token: "tag" },
22
 
23
      // Double and single quotes
24
      { regex: /"(?:[^\\]|\\.)*?"/, token: "string" },
25
      { regex: /'(?:[^\\]|\\.)*?'/, token: "string" },
26
 
27
      // Handlebars keywords
28
      { regex: />|[#\/]([A-Za-z_]\w*)/, token: "keyword" },
29
      { regex: /(?:else|this)\b/, token: "keyword" },
30
 
31
      // Numeral
32
      { regex: /\d+/i, token: "number" },
33
 
34
      // Atoms like = and .
35
      { regex: /=|~|@|true|false/, token: "atom" },
36
 
37
      // Paths
38
      { regex: /(?:\.\.\/)*(?:[A-Za-z_][\w\.]*)+/, token: "variable-2" }
39
    ],
40
    dash_comment: [
41
      { regex: /--\}\}/, pop: true, token: "comment" },
42
 
43
      // Commented code
44
      { regex: /./, token: "comment"}
45
    ],
46
    comment: [
47
      { regex: /\}\}/, pop: true, token: "comment" },
48
      { regex: /./, token: "comment" }
49
    ]
50
  });
51
 
52
  CodeMirror.defineMIME("text/x-handlebars-template", "handlebars");
53
});