Theming our Hello World module
The HelloWorldController
we built in Chapter 2, Creating Your First Module, currently uses a service to retrieve the string to be used as the salutation and then returns a simple markup render array with it. Let’s imagine now that we want to output this message but wrap it in our own specific markup. To make an easy thing complicated, we want to break up the salutation string into parts so that they can be styled slightly differently. Additionally, we want to allow others to override our theme using suggestions that depend on whether or not the salutation has been overridden via the configuration form. So, let’s see how we can do these things.
To get things started, this is the markup we are after:
<div class="salutation"> Good morning <span class="salutation—target">world</span> </div>
The first thing we need to do is to define our own theme hook capable of outputting...