[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/vendor/codemirror/mode/tornado/ -> tornado.js (source)

   1  // CodeMirror, copyright (c) by Marijn Haverbeke and others
   2  // Distributed under an MIT license: https://codemirror.net/5/LICENSE
   3  
   4  (function(mod) {
   5    if (typeof exports == "object" && typeof module == "object") // CommonJS
   6      mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"),
   7          require("../../addon/mode/overlay"));
   8    else if (typeof define == "function" && define.amd) // AMD
   9      define(["../../lib/codemirror", "../htmlmixed/htmlmixed",
  10              "../../addon/mode/overlay"], mod);
  11    else // Plain browser env
  12      mod(CodeMirror);
  13  })(function(CodeMirror) {
  14    "use strict";
  15  
  16    CodeMirror.defineMode("tornado:inner", function() {
  17      var keywords = ["and","as","assert","autoescape","block","break","class","comment","context",
  18                      "continue","datetime","def","del","elif","else","end","escape","except",
  19                      "exec","extends","false","finally","for","from","global","if","import","in",
  20                      "include","is","json_encode","lambda","length","linkify","load","module",
  21                      "none","not","or","pass","print","put","raise","raw","return","self","set",
  22                      "squeeze","super","true","try","url_escape","while","with","without","xhtml_escape","yield"];
  23      keywords = new RegExp("^((" + keywords.join(")|(") + "))\\b");
  24  
  25      function tokenBase (stream, state) {
  26        stream.eatWhile(/[^\{]/);
  27        var ch = stream.next();
  28        if (ch == "{") {
  29          if (ch = stream.eat(/\{|%|#/)) {
  30            state.tokenize = inTag(ch);
  31            return "tag";
  32          }
  33        }
  34      }
  35      function inTag (close) {
  36        if (close == "{") {
  37          close = "}";
  38        }
  39        return function (stream, state) {
  40          var ch = stream.next();
  41          if ((ch == close) && stream.eat("}")) {
  42            state.tokenize = tokenBase;
  43            return "tag";
  44          }
  45          if (stream.match(keywords)) {
  46            return "keyword";
  47          }
  48          return close == "#" ? "comment" : "string";
  49        };
  50      }
  51      return {
  52        startState: function () {
  53          return {tokenize: tokenBase};
  54        },
  55        token: function (stream, state) {
  56          return state.tokenize(stream, state);
  57        }
  58      };
  59    });
  60  
  61    CodeMirror.defineMode("tornado", function(config) {
  62      var htmlBase = CodeMirror.getMode(config, "text/html");
  63      var tornadoInner = CodeMirror.getMode(config, "tornado:inner");
  64      return CodeMirror.overlayMode(htmlBase, tornadoInner);
  65    });
  66  
  67    CodeMirror.defineMIME("text/x-tornado", "tornado");
  68  });


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer