A template engine interprets template source. Concatenating a user's name into that source can let text that looks like a placeholder become an instruction. Removing HTML tags doesn't fix that boundary, because a template expression may contain no tags at all.
Keep the template fixed and pass untrusted values through its data interface. Escape the resulting value for the output context. These labs use a small visible placeholder replacer to model the mistake. It recognizes a few named placeholders and never executes arbitrary code; it's not a production template engine. The fixed greeting inserts the name as escaped HTML text and preserves braces literally. A production integration must follow its engine's data API and escaping rules. Preserve ordinary punctuation, ampersands and markup-shaped text rather than deleting characters from the person's name.
Keep the template fixed and escape untrusted values for HTML.