1

I have data in CSV format:

$result->names = array(array('x,y,z'),array('a,b,c'));

for example:

item.names = 'a,b,c'

this code doesn't work:

<div tal:repeat="item result">
<div tal:repeat="x php:explode(',',${item.names})" tal:omit-tag="">
<span tal:content="x"></span>
</div></div>

but this code works, why?

<div tal:repeat="item result">
<div tal:repeat="x php:explode(',','a,b,c')" tal:omit-tag="">
<span tal:content="x"></span>
</div></div>
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Colargol
  • 749
  • 4
  • 14
  • 26

1 Answers1

1

Don't use ${} in expressions with php: modifier. That should work, assuming you're looping over value from $result->names:

<tal:block tal:repeat="x php:explode(',', item)">

(BTW: instead of omit-tag you can use tal:block element which is "invisible")

Kornel
  • 97,764
  • 37
  • 219
  • 309