Is there a way to share a template/markup with the JSON API so that it doesn’t need to be declared both in PHP and in JS?

Is there a way to share a template/markup with the JSON API so that it doesn’t need to be declared both in PHP and in JS?