Tiled Gallery: Extract HTML generation logic.

HTML generation logic is separated into templates and partials.
Tiled Gallery: Move function and make static.

Moved a function that builds the extra data for containers (for carousel) to the plugin file, since it is not in the responbility of the layout to build it and doesn't belong there.