Tables in template parameters were not intended to be used. In your case it moved the end of the image template way down in the edit mode. That makes it complicated to edit.
You have a simple solution, since you use the named ref tag twice. You can define the content on the 2nd usage and only use <ref name="marriage" /> in the template.