Twig split doesn't work properly when debug is set to on. I'm splitting title strings "backend developer", "content management", "project management" in two by using the following code:
{% set titles = fields.title.content|split(' ', 2) %}
<div class="heading-1">{{ attribute(titles, 0) }}</div>
<div class="heading-2">{{ attribute(titles, 1) }}</div>
If I turn off Twig debugging it works fine and displays correctly like this:
http://i.imgur.com/xW79S6R.png
But with Twig debugging on it displays the theme_hook suggestions:
http://i.imgur.com/nuOdH7i.png
Screenshots attached as well.
Comments
Comment #2
mahammedzkhan commentedComment #3
swentel commentedMoving to better component.
Comment #4
joelpittetNot sure how to resolve this one off hand but grab the
valueinstead of thecontentAnd split that? Likely you don't want to deal with HTML anyways?Comment #5
star-szrYes I agree with what @joelpittet said. Splitting HTML is going to be tricky and I don't think this is something core should try to hold your hand on.
I would argue this is not a bug but a result of how twig debug was designed to work.
Comment #6
joelpittetThis is likely going to be closed as "works as designed", but postponing on my question in #4
Comment #7
joelpittetTriage, closing as I mentioned to myself in #6. Re-open if you have more details to add.
Comment #8
adamps commentedI am tentatively re-opening this one as part of a larger META initiative #2914733: [META] twig debug can break parts of site.
Even if we can't solve this problem automatically, I feel it could be advantageous to document as far as possible all ways that turning twig debug on might break a site.
You could argue that now that I have linked this to the META that already provides some documentation, so I don't mind if you want to close it again.