Template partials look good, which is one of the key reasons frameworks like React are as good and popular as they are, because you can reuse small segments of code.
React allows for encapsulation of state in a reusable component, its more than just templating.
Everyone just busts out "React" for every small thing, but few commit to actually learning this pretty complicated technology.
The last two recent Cloudflare outages were because of React.