mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Reserve future support for comment line before a tag name
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
tag_never_closed: "'%{block_name}' tag was never closed"
|
||||
table_row: "Syntax Error in 'table_row loop' - Valid syntax: table_row [item] in [collection] cols=3"
|
||||
render: "Syntax error in tag 'render' - Template name must be a quoted string"
|
||||
inline_comment_invalid: "Syntax error in tag '#' - Each line of comments must be prefixed by the '#' character"
|
||||
argument:
|
||||
include: "Argument error in tag 'include' - Illegal template name"
|
||||
disabled:
|
||||
|
||||
@@ -2,6 +2,16 @@
|
||||
|
||||
module Liquid
|
||||
class InlineComment < Tag
|
||||
def initialize(tag_name, markup, options)
|
||||
super
|
||||
# Semantically, a comment should only ignore everything after it on the line.
|
||||
# Currently, this implementation doesn't support mixing a comment with another tag
|
||||
# but we need to reserve future support for this.
|
||||
if markup.match?(/\n\s*[^#]/)
|
||||
raise SyntaxError, options[:locale].t("errors.syntax.inline_comment_invalid")
|
||||
end
|
||||
end
|
||||
|
||||
def render_to_output_buffer(_context, output)
|
||||
output
|
||||
end
|
||||
|
||||
@@ -26,7 +26,9 @@ class InlineCommentTest < Minitest::Test
|
||||
|
||||
def test_comment_inline_tag
|
||||
assert_template_result('ok', '{% echo "ok" # output something from a tag %}')
|
||||
end
|
||||
|
||||
def test_comment_line_before_tag
|
||||
assert_template_result('ok', '{% # this sort of comment also
|
||||
echo "ok" %}')
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user