Browse code

Added {% raw %} liquid block, allowing for blocks of code which are not parsed by Liquid

Brandon Mathis authored on 07/09/2011 at 22:49:20
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,24 @@
0
+# Author: phaer, https://github.com/phaer
1
+# Source: https://gist.github.com/1020852
2
+# Description: Raw tag for jekyll. Keeps liquid from parsing text betweeen {% raw %} and {% endraw %}
3
+
4
+module Jekyll
5
+  class RawTag < Liquid::Block
6
+    def parse(tokens)
7
+      @nodelist ||= []
8
+      @nodelist.clear
9
+
10
+      while token = tokens.shift
11
+        if token =~ FullToken
12
+          if block_delimiter == $1
13
+            end_tag
14
+            return
15
+          end
16
+        end
17
+        @nodelist << token if not token.empty?
18
+      end
19
+    end
20
+  end
21
+end
22
+
23
+Liquid::Template.register_tag('raw', Jekyll::RawTag)