Compare commits

...

3 Commits

Author SHA1 Message Date
Sam Doiron
2d6bf406dd update grammar to support # 2021-01-29 17:06:16 -05:00
Sam Doiron
f331204f7c use Lua style syntax 2021-01-29 16:56:45 -05:00
Sam Doiron
5dcce427d0 Add inline comments syntax 2021-01-29 16:48:38 -05:00
3 changed files with 33 additions and 1 deletions

View File

@@ -4,7 +4,7 @@ require 'English'
module Liquid
class BlockBody
LiquidTagToken = /\A\s*(\w+)\s*(.*?)\z/o
LiquidTagToken = /\A\s*([\w#]+)\s*(.*?)\z/o
FullToken = /\A#{TagStart}#{WhitespaceControl}?(\s*)(\w+)(\s*)(.*?)#{WhitespaceControl}?#{TagEnd}\z/om
ContentOfVariable = /\A#{VariableStart}#{WhitespaceControl}?(.*?)#{WhitespaceControl}?#{VariableEnd}\z/om
WhitespaceOrNothing = /\A\s*\z/

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