#2124·liquid

`{% raw %}` does not close at the first `{% endraw %}` when its body contains `{{`

Author: Nuhiat-ArefinCreated Sep 23, 2026Updated Sep 23, 2026

{% raw %} does not close at the first {% endraw %} when its body contains {{

Version

  • liquid 5.14.0 (4e39ae4cc3da73921923c0669e0fc84a66b2f696)
  • Ruby 4.0.6, x86_64-linux

Steps to reproduce

ruby
require "liquid"

src = "{%raw%}%{{%endraw%}}{%raw%}x{%endraw%}"
puts Liquid::Template.parse(src, error_mode: :strict2).render.inspect

Actual behavior

"%{{%endraw%}}{%raw%}x"

The first {% endraw %} is not recognized because the raw body contains {{; raw mode continues until the next endraw, so {%endraw%}}{%raw%}x is rendered literally.

Expected behavior

The block should close at the first {% endraw %}, producing %{}x (as Python Liquid does). Per the documented raw semantics, content between {% raw %} and the first {% endraw %} is emitted literally; a {{ in the body should not prevent the closing tag from being recognized.

Impact

Templates that intentionally render literal {{ inside a {% raw %} block can swallow a later {% endraw %} and emit unintended literal text (and lose the closing tag).