I've seen a few Dart examples/tutorials that look like <template iterate="thing in collection">
and others that use <template repeat="thing in collection">
. They seem to do exactly the same thing. What's the difference between them and why is one recommended instead of the other in a given situation?
Here's straight from the changelog:
Added 'template-repeat' that, unlike template-iterate, if used as an attribute it repeats the tag instead of the children of the tag.
The reason is that following HTML is invalid for most HTML parsers:
<select>
<template iterate='name in results'>
<option>{{name}}</option>
</template>
</select>`
template
tag is not allowed within select
, so the solution is to use:
<select>
<option template repeat='name in results'>{{name}}</option>
</select>
template repeat
was added recently (April 2013), and it will replace template iterate
eventually, AFAIK, but at the moment both are supported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With