olado / doT

The fastest + concise javascript template engine for nodejs and browsers. Partials, custom delimiters and more.
Other
5.01k stars 1.02k forks source link

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

Closed gufoscuro closed 5 years ago

gufoscuro commented 5 years ago

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!

epoberezkin commented 5 years ago

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.

gufoscuro commented 5 years ago

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!