From 0a9ff4f55d1e2b0b3efb9ef4e3ebd0faf8610e64 Mon Sep 17 00:00:00 2001 From: Bernie Telles Date: Thu, 5 Apr 2012 09:29:45 -0700 Subject: [PATCH] Add sample docs for liquid. --- demo/kitchen-sink/demo.js | 5 ++ demo/kitchen-sink/docs/liquid.liquid | 76 ++++++++++++++++++++++++++ lib/ace/mode/liquid_highlight_rules.js | 19 +++---- 3 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 demo/kitchen-sink/docs/liquid.liquid diff --git a/demo/kitchen-sink/demo.js b/demo/kitchen-sink/demo.js index 5a5374da..af40fea3 100644 --- a/demo/kitchen-sink/demo.js +++ b/demo/kitchen-sink/demo.js @@ -98,6 +98,7 @@ var modes = [ new Mode("json", "JSON", ["json"]), new Mode("latex", "LaTeX", ["tex"]), new Mode("lua", "Lua", ["lua"]), + new Mode("liquid", "Liquid", ["liquid"]), new Mode("markdown", "Markdown", ["md", "markdown"]), new Mode("ocaml", "OCaml", ["ml", "mli"]), new Mode("perl", "Perl", ["pl", "pm"]), @@ -189,6 +190,10 @@ var docs = [ "lua", "Lua", require("ace/requirejs/text!./docs/lua.lua") ), + new Doc( + "liquid", "Liquid", + require("ace/requirejs/text!./docs/liquid.liquid") + ), new Doc( "java", "Java", require("ace/requirejs/text!./docs/java.java") diff --git a/demo/kitchen-sink/docs/liquid.liquid b/demo/kitchen-sink/docs/liquid.liquid new file mode 100644 index 00000000..29c0b016 --- /dev/null +++ b/demo/kitchen-sink/docs/liquid.liquid @@ -0,0 +1,76 @@ +The following examples can be found in full at http://liquidmarkup.org/ + +Liquid is an extraction from the e-commerce system Shopify. +Shopify powers many thousands of e-commerce stores which all call for unique designs. +For this we developed Liquid which allows our customers complete design freedom while +maintaining the integrity of our servers. + +Liquid has been in production use since June 2006 and is now used by many other +hosted web applications. + +It was developed for usage in Ruby on Rails web applications and integrates seamlessly +as a plugin but it also works excellently as a stand alone library. + +Here's what it looks like: + + + + +Some more features include: + +

Filters

+

The word "tobi" in uppercase: {{ 'tobi' | upcase }}

+

The word "tobi" has {{ 'tobi' | size }} letters!

+

Change "Hello world" to "Hi world": {{ 'Hello world' | replace: 'Hello', 'Hi' }}

+

The date today is {{ 'now' | date: "%Y %b %d" }}

+ + +

If

+

+ {% if user.name == 'tobi' or user.name == 'marc' %} + hi marc or tobi + {% endif %} +

+ + +

Case

+

+ {% case template %} + {% when 'index' %} + Welcome + {% when 'product' %} + {{ product.vendor | link_to_vendor }} / {{ product.title }} + {% else %} + {{ page_title }} + {% endcase %} +

+ + +

For Loops

+

+ {% for item in array %} + {{ item }} + {% endfor %} +

+ + +

Tables

+

+ {% tablerow item in items cols: 3 %} + {% if tablerowloop.col_first %} + First column: {{ item.variable }} + {% else %} + Different column: {{ item.variable }} + {% endif %} + {% endtablerow %} +

diff --git a/lib/ace/mode/liquid_highlight_rules.js b/lib/ace/mode/liquid_highlight_rules.js index 2b9b154a..5a0c7c8a 100644 --- a/lib/ace/mode/liquid_highlight_rules.js +++ b/lib/ace/mode/liquid_highlight_rules.js @@ -142,8 +142,15 @@ var LiquidHighlightRules = function() { regex : ".+" } ] , - liquid_start : [ - { + liquid_start : [{ + token: "variable", + regex: "}}", + next: "start" + }, { + token: "variable", + regex: "%}", + next: "start" + }, { token : "string", // single line regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' }, { @@ -184,14 +191,6 @@ var LiquidHighlightRules = function() { }, { token : "text", regex : "\\s+" - }, { - token: "variable", - regex: "%}", - next: "start" - }, { - token: "variable", - regex: "}}", - next: "start" }, ] };