Child templates extend a layout block with {{ block.super }}. With the strictVariables option turned on, rendering fails with "undefined variable: block.super". Without strict mode it renders, but block.super does not be…
Child templates extend a layout block with {{ block.super }}. With the strictVariables option turned on, rendering fails with "undefined variable: block.super". Without strict mode it renders, but block.super does not behave like a value: filters, assign and conditions see nothing, and the parent content is written out in the wrong place.
Templates are supplied through the templates engine option.
parent.html set to {% block css %}<link href="base.css" rel="stylesheet">{% endblock %} and strictVariables: true, render {% layout "parent.html" %}{%block css%}{{block.super}}<link href="extra.css" rel="stylesheet">{%endblock%}.parent set to {% block a %}base{% endblock %} and no strict mode, render {% layout "parent" %}{%block a%}{{block.super | upcase}}{%endblock%}.parent, render {% layout "parent" %}{%block a%}{% assign s = block.super %}[{{ s }}]{%endblock%}.<link href="base.css" rel="stylesheet"><link href="extra.css" rel="stylesheet">BASE[base]undefined variable: block.superbasebase[]{{ block.super }} without strict mode already renders correctly.block.super already works in strict mode.block.super should work through several levels of layouts.Adapted from harttle/liquidjs (MIT).
Visible test command
TZ=UTC npx --no-install jest --ci --coverage=falseThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
block-super-fails-in-strict-mode
Changes under src/ are evaluated.