Q: Parse HTML content in CodeIgniter 4 I'm using Codeigniter 4.
$template = 'Hello, {firstname} {lastname}';
$data = [
    'title' => 'Mr',
    'firstname' => '<h1>John</h1>',
    'lastname' => 'Doe'
];

$parser = \Config\Services::parser();
echo $parser->setData($data)->renderString($template);

This is producing,

But adding htmlspecialchars_decode() with this is working properly.
echo htmlspecialchars_decode($parser->setData($data)->renderString($template));

My question is, is it the right way? Why I need to add this raw function? Is there any parameter or something for this? This was working in CI3.
Thanks in advance.

A: You just need to skip the escape.
As when using a pseudo variable in template file just put ! before and after the variable.
So, the variable to have as below:
$template = 'Hello, {!firstname!} {lastname}';

