You can you the more accepted method of query's data:

```coffeescript
index = $(@).data('hasManyIndex') || $(@).siblings('fieldset').length
$(@).data('hasManyIndex', index++);

#...
$(@).before unescape_html $(@).data('html').replace regex, has_many_index
```