Dumping output from template_init()
From what I see, you could use two different methods: Ternaries and switches:



From a switch point of view, you could use the following to proceed:

function mytemplate_init() {
    switch(request_path()) {
       case "widgets_json":
           drupal_json_output(_get_widgets());
       break;
       case "people_json":
           drupal_json_output(_get_people());
       break;
    }
}




Or, one can replace that with a ternary to shorten it:


if (request_path() == "widgets_json") {
    drupal_json_output(_get_widgets());
    exit;
}
if (request_path() == "people_json") {
    drupal_json_output(_get_people());
    exit;
}



into:

request_path() == "widgets_json" ? drupal_json_output(_get_widgets()) : (request_path() == "people_json" ? drupal_json_output(_get_people()) : "" )
exit;


The shortside to ternaries is that you sacrifice readability for effectiveness.

However, if you can move past that, ternaries are an effective part of a Programmer's Toolbelt(TM)



Or, as I've since come to understand, we can use objects!

$functions = [
       "widgets_json" =&gt; _get_widgets,
       "people_json"  =&gt; _get_people
     ];
$functions[request_path()]();




Unfortunately, with such a small amount of code supplied, very little can be reviewed.