{"record":{"id":"b819814072daba9a","repo":"Shopify/liquid","slug":"errors-syntax-inline-comment-invalid","errorCode":"errors.syntax.inline_comment_invalid","errorMessage":"options[:locale].t(\"errors.syntax.inline_comment_invalid\")","messagePattern":"options\\[:locale\\]\\.t\\(\"errors\\.syntax\\.inline_comment_invalid\"\\)","errorType":"exception","errorClass":"Liquid::SyntaxError","httpStatus":null,"severity":"error","filePath":"lib/liquid/tags/inline_comment.rb","lineNumber":16,"sourceCode":"# frozen_string_literal: true\n\nmodule Liquid\n  class InlineComment < Tag\n    def initialize(tag_name, markup, options)\n      super\n\n      # Semantically, a comment should only ignore everything after it on the line.\n      # Currently, this implementation doesn't support mixing a comment with another tag\n      # but we need to reserve future support for this and prevent the introduction\n      # of inline comments from being backward incompatible change.\n      #\n      # As such, we're forcing users to put a # symbol on every line otherwise this\n      # tag will throw an error.\n      if markup.match?(/\\n\\s*[^#\\s]/)\n        raise SyntaxError, options[:locale].t(\"errors.syntax.inline_comment_invalid\")\n      end\n    end\n\n    def render_to_output_buffer(_context, output)\n      output\n    end\n\n    def blank?\n      true\n    end\n  end\nend\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/Shopify/liquid/blob/807d45a6b3d4568e64e86b375e3702df2c7c860c/lib/liquid/tags/inline_comment.rb#L1-L29","documentation":"The {% # %} inline comment tag (Liquid 5.x, error_mode-aware) raises SyntaxError when a line inside the comment starts with something other than a '#' character. Inline comments require every continued line to begin with '#', reserving future multiline semantics and preventing backward-incompatible usage.","triggerScenarios":"An inline comment containing a newline followed by non-'#', non-whitespace text, e.g. {% # line one\nline two %} or {% # comment\n  code_here %}.","commonSituations":"Writing multi-line notes in an inline comment assuming block-comment behavior; pasting multiline text into a {% # %} tag; upgrading to Liquid 5 and discovering inline comment restrictions.","solutions":["Prefix every line of the comment with #: {% # line one\n# line two %}","Keep the comment on a single line, or split into multiple {% # ... %} tags","Use {% comment %}...{% endcomment %} for multiline comments instead"],"exampleFix":"// before\n{% # this is\na multiline comment %}\n// after\n{% # this is\n# a multiline comment %}","handlingStrategy":"validation","validationCode":"raise Liquid::SyntaxError, 'inline comment lines must start with #' if markup.to_s.match?(/\\n\\s*[^#\\s]/)","typeGuard":"def valid_inline_comment?(markup)\n  !markup.to_s.match?(/\\n\\s*[^#\\s]/)\nend","tryCatchPattern":"begin\n  Liquid::Template.parse(template)\nrescue Liquid::SyntaxError => e\n  logger.error(\"Invalid inline comment: #{e.message}\")\n  raise\nend","preventionTips":["Prefix every comment line with #","Use {% comment %}...{% endcomment %} for multiline notes","After upgrading to Liquid 5, audit templates that used inline comments"],"tags":["ruby","liquid","template-syntax","comments"],"backgroundTag":"template-syntax-error","analyzedSha":"807d45a6b3d4568e64e86b375e3702df2c7c860c","analyzedAt":"2026-09-08T11:31:38.917Z","contentChangedAt":"2026-09-08T11:31:38.917Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}