Another implementation would be:
```coffee
if parent.data 'has_many_index'
  parent.data has_many_index: parent.data('has_many_index') + 1
else
  parent.data has_many_index: parent.find('fieldset').length

regex = new RegExp elem.data('placeholder'), 'g'
html  = elem.data('html').replace regex, parent.data('has_many_index')