Create a Component, register it in the bootstrap, and call it in the volt template like {{ myComponent.myFunction("myParam") }}. In the function, you will return a string that contains that HTML code (beware of autoescape, it will affect the returned string).