Register WordPress page templates via functions file

Recently when creating an Angular theme using the WordPress REST API, I came across a situation where i needed to set the page template but had no need for the php template file.

Using the theme_page_templates filter we can registered a custom template that appears in the page attributes template dropdown.

/**
 * Register Homepage Template
 */
function jc_register_page_templates($templates){
  $templates['home'] = 'Homepage';
  return $templates;
}
add_filter('theme_page_templates', 'jc_register_page_templates');