Shopify/liquid · error · Liquid::SyntaxError

errors.syntax.render

errors.syntax.render

Error message

options[:locale].t("errors.syntax.render")

What it means

The {% render %} tag parser raises Liquid::SyntaxError when the tag's markup does not match its SYNTAX regex (a template name, optional with/for parameter, and optional alias). The message is fetched from the locale file under errors.syntax.render. It means Liquid could not interpret the arguments given to a render tag.

Solutions

  1. Ensure the render tag includes a valid quoted template name: {% render 'template-name' %}.
  2. Check the with/for clause syntax: {% render 'x' with obj as alias %} or {% render 'x' for list as alias %}.
  3. Escape or remove Liquid-like text in templates that is not meant to be parsed.
  4. Validate templates programmatically with Template.parse before deploying so the failing tag/line is reported early.

Example fix

// before
{% render products %}
// after
{% render 'products' %}
Defensive patterns

Strategy: validation

Validate before calling

markup = "'products' with collection as items"
raise Liquid::SyntaxError, 'invalid render tag' unless markup =~ Liquid::Render::SYNTAX

Type guard

def valid_render_markup?(markup)
  markup.is_a?(String) && markup.match?(Liquid::Render::SYNTAX)
end

Try / catch

begin
  template = Liquid::Template.parse(source)
rescue Liquid::SyntaxError => e
  logger.error("Liquid syntax error: #{e.message}")
  raise
end

Prevention

When it happens

Trigger: A {% render %} tag whose markup fails the SYNTAX regexp: e.g. {% render %} with no template name, {% render 'x' with foo alias2 %} with a malformed alias, or unquoted/invalid expressions passed to strict_parse via strict_parse(markup).

Common situations: Typos in render tags inside themes; dynamically generated template tags where the template name ends up empty; copying for-loop style syntax ({% render item of items %}) that the tag grammar does not accept.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Shopify/liquid@807d45a6b3 (2026-09-08). Data as JSON: /api/errors/e403e82fe9e48128. Report an issue: GitHub.

Appendix: source

Thrown at lib/liquid/tags/render.rb:119

        key = p.consume
        p.consume(:colon)
        @attributes[key] = safe_parse_expression(p)
        p.consume?(:comma)
      end

      p.consume(:end_of_string)
    end

    def strict2_template_name(p)
      p.consume(:string)
    end

    def strict_parse(markup)
      lax_parse(markup)
    end

    def lax_parse(markup)
      raise SyntaxError, options[:locale].t("errors.syntax.render") unless markup =~ SYNTAX

      template_name = Regexp.last_match(1)
      with_or_for = Regexp.last_match(3)
      variable_name = Regexp.last_match(4)

      @alias_name = Regexp.last_match(6)
      @variable_name_expr = variable_name ? parse_expression(variable_name) : nil
      @template_name_expr = parse_expression(template_name)
      @is_for_loop = (with_or_for == FOR)

      @attributes = {}
      markup.scan(TagAttributes) do |key, value|
        @attributes[key] = parse_expression(value)
      end
    end

    class ParseTreeVisitor < Liquid::ParseTreeVisitor
      def children

View on GitHub (pinned to 807d45a6b3)