Sha256: a7d9ac682abce33ba25327c65fdf658dc646108aa2111f3a90e1fc660017bbce

Contents?: true

Size: 1.07 KB

Versions: 22

Compression:

Stored size: 1.07 KB

Contents

/*
  This overlay provides a 'liquid' mode to the excellent CodeMirror editor (http://codemirror.net/).
  Add something like this to your CSS:

    .cm-liquid-tag {
      color: #32273f;
      background: #ead9ff;
    }

    .cm-liquid-variable {
      color: #29739b
      background: #c2e0f0;
    }

  https://gist.github.com/1356686
*/

CodeMirror.defineMode("liquid", function(config, parserConfig) {
  var liquidOverlay = {
    token: function(stream, state) {

      // Variables.
      if (stream.match("{{")) {
        while ((ch = stream.next()) != null)
          if (ch == "}" && stream.next() == "}") break;
        return "liquid-variable";
      }

      // Tags.
      if(stream.match("{%")) {
        while ((ch = stream.next()) != null)
          if (ch == "%" && stream.next() == "}") break;
        return "liquid-tag";
      }

      while (stream.next() != null && !stream.match("{{", false) && !stream.match("{%", false)) {}
      return null;
    }
  };

  return CodeMirror.overlayParser(CodeMirror.getMode(config, parserConfig.backdrop || "text/html"), liquidOverlay);
});

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
locomotive_cms-2.0.0.rc2 vendor/assets/javascripts/locomotive/liquid_mode.js
locomotive_cms-2.0.0.rc1 vendor/assets/javascripts/locomotive/liquid_mode.js