{"record":{"id":"72aa546c431d05ac","repo":"Shopify/liquid","slug":"errors-syntax-include","errorCode":"errors.syntax.include","errorMessage":"options[:locale].t(\"errors.syntax.include\")","messagePattern":"options\\[:locale\\]\\.t\\(\"errors\\.syntax\\.include\"\\)","errorType":"exception","errorClass":"Liquid::SyntaxError","httpStatus":null,"severity":"error","filePath":"lib/liquid/tags/include.rb","lineNumber":135,"sourceCode":"\n    def lax_parse(markup)\n      if markup =~ SYNTAX\n        template_name = Regexp.last_match(1)\n        with_or_for   = Regexp.last_match(3)\n        variable_name = Regexp.last_match(4)\n\n        @alias_name         = Regexp.last_match(6)\n        @variable_name_expr = variable_name ? parse_expression(variable_name) : nil\n        @template_name_expr = parse_expression(template_name)\n        @is_for_loop        = (with_or_for == FOR)\n        @attributes         = {}\n\n        markup.scan(TagAttributes) do |key, value|\n          @attributes[key] = parse_expression(value)\n        end\n\n      else\n        raise SyntaxError, options[:locale].t(\"errors.syntax.include\")\n      end\n    end\n\n    class ParseTreeVisitor < Liquid::ParseTreeVisitor\n      def children\n        [\n          @node.template_name_expr,\n          @node.variable_name_expr,\n        ] + @node.attributes.values\n      end\n    end\n  end\nend\n","sourceCodeStart":117,"sourceCodeEnd":149,"githubUrl":"https://github.com/Shopify/liquid/blob/807d45a6b3d4568e64e86b375e3702df2c7c860c/lib/liquid/tags/include.rb#L117-L149","documentation":"Include#lax_parse raises SyntaxError when the {% include %} markup doesn't match its expected grammar: a template name (string literal or variable) optionally followed by 'with x' or 'for x' and attribute assignments. Falling into the else branch means the whole markup was unparseable even in lenient mode.","triggerScenarios":"Markup like {% include %} (no name), {% include 'a' 'b' %}, or include tags with stray tokens that match neither the TemplateName+with/for pattern nor TagAttributes.","commonSituations":"Deleted partial name after refactoring; quoting/typo issues such as {% include 'partial.html %} (unclosed quote); copying {% render %} syntax that include doesn't accept.","solutions":["Give the include a valid name: {% include 'header' %} or {% include partial_name %}","Use the supported modifiers: {% include 'card' with product %} or {% include 'item' for items %} (not both mixed arbitrarily)","Check for unclosed quotes or duplicated tokens in the tag"],"exampleFix":"// before\n{% include %}\n// after\n{% include 'product_card' %}","handlingStrategy":"validation","validationCode":"valid = markup =~ /\\A\\s*(\\\"[^\\\"]+\\\"|'[^']+'|[\\w\\-\\.]+)(\\s+(with|for)\\s+\\S+)?(\\s*\\w+\\s*=\\s*\\S+)*\\s*\\z/\nraise Liquid::SyntaxError, 'invalid include markup' unless valid","typeGuard":"def valid_include_tag?(markup)\n  !markup.to_s.strip.empty? && markup !~ /\\A\\s*\\z/\nend","tryCatchPattern":"begin\n  Liquid::Template.parse(template)\nrescue Liquid::SyntaxError => e\n  logger.error(\"Invalid include tag: #{e.message}\")\n  fallback_template\nend","preventionTips":["Always provide a template name in include tags","Quote literal names with single quotes: include 'name'","Check for unclosed quotes when editing templates by hand"],"tags":["ruby","liquid","template-syntax"],"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"}