-
-
Notifications
You must be signed in to change notification settings - Fork 372
Open
Labels
Description
Reproducer: https://github.com/jrushlow/bug-demo-verbatim-in-twig
Stacktrace: https://github.com/jrushlow/bug-demo-verbatim-in-twig/blob/9c7e2df445193d2fa5ffd415763e57ed82d961f5/templates/base.html.twig#L70
Anonymous Component
// components/Code.html.twig
<p>{% block content %}{% endblock %}</p>
🆗 We can render that component by
// base.html.twig
<twig:Code>Howdy!</twig:Code>
⛔ We can trigger a Twig\Error\SyntaxError
by doing:
// base.html.twig
<twig:Code>{% verbatim %}Howdy!{% endverbatim %}</twig:Code>
A template that extends another one cannot include content outside Twig blocks. Did you forget to put the content inside a {% block %} tag?
❗ This works - but counterintuitive to how we use components
// base.html.twig
<twig:Code>{% block content %}{% verbatim %}Howdy!{% endverbatim %}{% endblock %}</twig:Code>
What context is the {% block content %}
? E.g. are we creating a new content
block in base.html.twig
or are we redefining the existing content
block that already exists in the component? Beats me... I'm still trying to sort that out..
I'm not sure if this is a twig/twig
problem or a ux
problem. Logically thinking - I would expect that when I use verbatim
tags - under the hood:
- the content within the tag is not parsed (think of a "CodeBlock" component where we want to show twig syntax)
- the "result" of
verbatim
is passed to the component. - the component renders the
string
provided in thecontent
context
Thoughts?