olado/doT

improvement: add a simple way to loop through a key/val map

gufoscuro opened this issue · 2 comments

Forgive me if this is just gibberish, but I didn't find an actual simple way to go through a map, just like you do for an array. Wouldn't be possible to do something working like this?

{{~it.request.querystring :key:val}}
{{=key}} => {{=val}}
{{~}}

Thanks!

You can use plain plain JavaScript in dot and iterate maps using for-in loop. The reason not to use maps in the templates is that the order of keys is not guaranteed, and in most cases when you render a map, the order of keys is important.

I know you can use a for-in, I just wanted to know if a "more friendly syntax" was in the roadmap.
Actually a map itself doesn't guarantee the order, so it doesn't matter how it is rendered, but thanks for the quick turnaround!