Skip to content

Commit

Permalink
Reserve future support for comment line before a tag name
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanahsmith committed Feb 26, 2021
1 parent ab45548 commit 11ce2a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/liquid/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions lib/liquid/tags/inline_comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

module Liquid
class InlineComment < Tag
def initialize(tag_name, markup, options)
super
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
Expand Down
2 changes: 2 additions & 0 deletions test/integration/tags/inline_comment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def test_tag_ws_stripping

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
Expand Down

0 comments on commit 11ce2a6

Please sign in to comment.