Rendering Module Code to HTML Semi-new to Drupal. I'm trying to find a way to render HTML inside my custom module. 

Right now I'm using this method 

$page = 'hello world';
return $page;


Which can get pretty dirty once you had some logic into it. 

Is there a better way to do this? Maybe render it to some kind of template file and pass an array of vars?

Any help is appreciated :)
Clive is right that using the drupal theme system is your best bet if you're going to be doing significant variable manipulation but if you just want to load a big blob of HTML into your module you can do it a couple of ways in PHP.

For short blobs, try the EOF method

$str = &lt;&lt;&lt;EOF
  &lt;p&gt;Hello&lt;/p&gt;
  &lt;p&gt;$world&lt;/p&gt;
  ... etc.      
EOF;


For longer blobs, use file_get_contents()

$myhtml = file_get_contents(path_to_module().'/my_html.tpl');