mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-26 13:45:13 -07:00
Add raw tag. Fixes #37.
Thanks to phaer: https://gist.github.com/1020852 YO DAWG, WE HEARD YOU LIKE LIQUID SO WE PUT A RAW TAG IN YOUR LIQUID SO YOU CAN HAVE LIQUID IN YOUR LIQUID
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
module Liquid
|
||||||
|
class Raw < Block
|
||||||
|
def parse(tokens)
|
||||||
|
@nodelist ||= []
|
||||||
|
@nodelist.clear
|
||||||
|
|
||||||
|
while token = tokens.shift
|
||||||
|
if token =~ FullToken
|
||||||
|
if block_delimiter == $1
|
||||||
|
end_tag
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@nodelist << token if not token.empty?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Template.register_tag('raw', Raw)
|
||||||
|
end
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class RawTest < Test::Unit::TestCase
|
||||||
|
include Liquid
|
||||||
|
|
||||||
|
def test_tag_in_raw
|
||||||
|
assert_template_result '{% comment %} test {% endcomment %}',
|
||||||
|
'{% raw %}{% comment %} test {% endcomment %}{% endraw %}'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_output_in_raw
|
||||||
|
assert_template_result '{{ test }}',
|
||||||
|
'{% raw %}{{ test }}{% endraw %}'
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user