CodeIgniter Forums
how to use template parser? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: how to use template parser? (/thread-68866.html)



how to use template parser? - jaynarayan - 09-06-2017

I am following the docs but get white blank page.

following is my code


PHP Code:
<?php namespace App\Controllers;

use 
CodeIgniter\Controller;

class 
Home extends Controller
{
    public function 
index()
    {
        
        
$v = \Config\Services::parser();
        
$data['name']='jay';
        echo 
$v->setData($data)->render('template');
        echo 
'ok';
    }

    
//--------------------------------------------------------------------



it gives error of invalidargumentexception.

my template code is 


Code:
<!doctype html>
<html>
<head>
<title>Welcome to CodeIgniter</title>

<link rel="shortcut icon" type="image/png" href="/favicon.ico"/>
</head>
<body>
<h1>Testing parser class</h1>
{name}
</body>

</html>



RE: how to use template parser? - InsiteFX - 09-06-2017

// this is the right way
PHP Code:
$v = \Config\Services::parser(); 


It could be that the parser is not completed yet...

Hope that helps.


RE: how to use template parser? - kilishan - 09-06-2017

The issue with the Parser has been resolved. You should be good now.


RE: how to use template parser? - jaynarayan - 09-06-2017

(09-06-2017, 08:47 PM)kilishan Wrote: The issue with the Parser has been resolved.  You should be good now.

Thanks Smile