I recently wrote my first WP plugin that adds a shortcode for embedding a custom jquery image gallery into posts. It's primarily just dumps a good chunk of HTML into the post, along with javascript necessary for initialization. 

However, I had to build the HTML output procedurally, as a string in PHP. This kind of tag soup always drives me nuts, and I'm used to working with MVC frameworks which provide things like helper functions and partial templates for generating HTML.

What is the general approach for plugin authors who need to manage large amounts of dynamically built HTML or JS?