posthtml / posthtml-expressions

Use variables, JS-like expressions, and even markup-powered logic in your HTML.
Other
123 stars 20 forks source link

test: inline loop data #146

Open cossssmin opened 1 year ago

cossssmin commented 1 year ago

Trying to figure out how to pass an object to the loop attribute, added the test as a way of reproducing the issue.

These don't work, you'll get SyntaxError: Unexpected token \':\':

<each loop='key, value in {foo: "bar", baz: "qux"}'>
  <p>{{key}}: {{value}}</p>
</each>
<each loop='key, value in {"foo": "bar", "baz": "qux"}'>
  <p>{{key}}: {{value}}</p>
</each>

Meanwhile arrays work perfectly fine:

<each loop='item, index in [1,2,3]'>
  <p>{{index}}: {{item}}</p>
</each>

@Scrum am I doing something wrong, or are objects passed like that just not supported?