diff --git a/lib/liquid/tags/raw.rb b/lib/liquid/tags/raw.rb new file mode 100644 index 00000000..9c07d66e --- /dev/null +++ b/lib/liquid/tags/raw.rb @@ -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 + diff --git a/test/lib/liquid/tags/raw_test.rb b/test/lib/liquid/tags/raw_test.rb new file mode 100644 index 00000000..89cc495d --- /dev/null +++ b/test/lib/liquid/tags/raw_test.rb @@ -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