What is the best technique to do this the Drupal 8 way? I can imagine two strategies:
Each page will be a separate function within my controller. The function can first add two entries to the output array, the first will contain the data for the library, and the second the raw HTML and text.
In the second technique, I would place all the HTML and text in a twig template. Then I would add all the data for the library in the controller and add a reference to this new theme template as a second entry in the output array. I like the idea of this second strategy, but I don't know how to accomplish it. I've look at code for several Drupal 8 projects and read a few tutorials, and I haven't seen an example of this. The hook_theme function always contains a single return statement. How would I add a switch or if statement within
hook_themeto determine which twig template to return.
If there is a third option that is even better, let me know.