troubleshooting Question

Unable to parse "key=date"...

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
4 Comments2 Solutions118 ViewsLast Modified:
Here's my code:

			 {% for key, val in activity.meta %}
				<div class="box-item">
					{{% if key=="date" }}
					good times
					{{ %endif %}}
                {% endfor %} 

Open in new window

The "for" loop works fine (this is a working app that I've been asked to do so changes on). What I need to do is capture the date (see screenshot below) and reformat it. I'm spitting in the wind, though, as far as how the data is actually being processed.

When I run the above code, I get this error:

Error compiling twig template C:\wamp64\www\bSmart\views\partials\company-slide-out\history-tab.html.twig:
TwigException: Unable to parse 'if key=="date"' at template position1
Error parsing twig template C:\wamp64\www\bSmart\views\companies-edit.html.twig:
TypeError: Cannot read property 'length' of undefined

So, I'm thinking "date" is not the name of the key. So, how do I determine the name...?

Is there a way to view the array as it's coming to the twig file so I can see the key->value pairs and know what those keys are specifically?

If this was a JS file, I would do a console.log. Right now, while I have an idea as to where the data is coming from, I'm not certain at this point and that may be another question for EE down the road.

Is there a way to see the raw data in the context of a twig file?

Here's the screenshot I mentioned earlier:

What do you think?
Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros