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

mahammedzkhan created an issue. See original summary.

mahammedzkhan’s picture

Component: views.module » field system
swentel’s picture

Component: field system » theme system

Moving to better component.

joelpittet’s picture

Not sure how to resolve this one off hand but grab the value instead of the content And split that? Likely you don't want to deal with HTML anyways?

Cottser’s picture

Issue tags: -drupal8, -split, -Debug

Yes 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.

joelpittet’s picture

Status: Active » Postponed (maintainer needs more info)

This is likely going to be closed as "works as designed", but postponing on my question in #4

joelpittet’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Triage, closing as I mentioned to myself in #6. Re-open if you have more details to add.