function perch_template($tpl, $vars = array(), $return = false)
{
    $Template = new PerchTemplate($tpl);
    if (!is_array($vars)) {
        PerchUtil::debug('Non-array content value passed to perch_template.', 'error');
        $vars = array();
    }
    if (count($vars) == 0) {
        $Template->use_noresults();
    }
    if (!PerchUtil::is_assoc($vars)) {
        $html = $Template->render_group($vars, true);
    } else {
        $html = $Template->render($vars);
    }
    $html = $Template->apply_runtime_post_processing($html);
    if ($return) {
        return $html;
    }
    echo $html;
    PerchUtil::flush_output();
}