Add inline comments syntax

This commit is contained in:
Sam Doiron
2021-01-29 16:48:38 -05:00
parent 3c499d0241
commit 5dcce427d0
2 changed files with 32 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
# frozen_string_literal: true
module Liquid
class InlineComment < Tag
def blank?
true
end
def render_to_output_buffer(_context, _output)
end
end
Template.register_tag('#', InlineComment)
end

View File

@@ -0,0 +1,17 @@
# frozen_string_literal: true
require 'test_helper'
class InlineCommentTest < Minitest::Test
include Liquid
def test_basic_usage
template_source = <<-END_TEMPLATE
foo{% # this is a comment %}bar
END_TEMPLATE
template = Template.parse(template_source)
rendered = template.render!
assert_equal("foobar", rendered.strip)
end
end