Welcome Guest, Not a member yet? Register   Sign In
Parse HTML content in CodeIgniter 4
#1

(This post was last modified: 03-20-2021, 11:52 PM by ciddict.)

I'm using Codeigniter 4.

PHP Code:
$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,

[Image: 7QB0n.png]
But adding htmlspecialchars_decode() with this is working properly.

PHP Code:
echo htmlspecialchars_decode($parser->setData($data)->renderString($template)); 


[Image: 67Lgu.png]
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.
Reply


Messages In This Thread
Parse HTML content in CodeIgniter 4 - by ciddict - 03-20-2021, 11:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB