Open jrushlow opened 7 months ago
You should use endverbatim .. is this a typo in this message ?
Ha yes.. good catch - just a typo in the issues
Without the "{{" in the template does it still fail .?
Ya, the {
escapes are just to show the literal {
if you spinup the reproducer with symfony-cli
and goto /
Referencing https://github.com/jrushlow/bug-demo-verbatim-in-twig/blob/9c7e2df445193d2fa5ffd415763e57ed82d961f5/templates/base.html.twig#L14C29-L14C34 and https://github.com/jrushlow/bug-demo-verbatim-in-twig/blob/9c7e2df445193d2fa5ffd415763e57ed82d961f5/templates/base.html.twig#L21
if you were to remove everything and just have a template with:
// tmp.html.twig
<twig:Code>
{% verbatim %}
{{ include('a-file') }}
{% endverbatim %}
</twig:Code>
We'd still get the error
So this is the same with embed, you'd have to use
{% embed 'components/Code.html.twig' %}
{% block content %}
{% verbatim %}
AA
{% endverbatim %}
{% endblock %}
{% endembed %}
So clearly something is not interpreted correctly in the lexer, but i suggest you indeed use the weird but safe option in the meantime :)
// tmp.html.twig
<twig:Code>
{% block content %}
{% verbatim %}
{{ include('a-file') }}
{% endverbatim %}
{% endblock %}
</twig:Code>
Hey, thanks for your report! There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?
Hello? This issue is about to be closed if nobody replies.
Hey,
I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!
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
:ok: We can render that component by
:no_entry: We can trigger a
Twig\Error\SyntaxError
by doing:A template that extends another one cannot include content outside Twig blocks. Did you forget to put the content inside a {% block %} tag?
:exclamation: This works - but counterintuitive to how we use components
What context is the
{% block content %}
? E.g. are we creating a newcontent
block inbase.html.twig
or are we redefining the existingcontent
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 aux
problem. Logically thinking - I would expect that when I useverbatim
tags - under the hood:verbatim
is passed to the component.string
provided in thecontent
contextThoughts?