PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue May 23, 2017 5:34 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Dec 29, 2016 4:01 pm 
Offline
Forum Contributor
User avatar

Joined: Wed May 14, 2014 12:18 pm
Posts: 317
I just want to beable to use simple twig syntex in my PHP files and so i have the following code i used composer to install twig and added the following lines of code to my index.php file:

Syntax: [ Download ] [ Hide ]
require 'vendor/autoload.php';
$loader = new Twig_Loader_Filesystem('twig_templating');
$twig = new Twig_Environment($loader);
 


Now when i do the following in my index.php file:

Syntax: [ Download ] [ Hide ]
{{ 'yes' }}
 


I get the following error:

Syntax: [ Download ] [ Hide ]
Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\twig_templating\index.php on line 9


How do i use twig for templating in my php files ??


Top
 Profile  
 
PostPosted: Sat Dec 31, 2016 10:58 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6243
Location: Montreal, Canada
You haven't really shown much code. Are you calling render on your Twig object? That will return the HTML which you will then display, usually through a Response object.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Sat Dec 31, 2016 11:04 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6243
Location: Montreal, Canada
Have you read this? http://twig.sensiolabs.org/doc/api.html

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Sun Jan 01, 2017 10:09 am 
Offline
Forum Contributor
User avatar

Joined: Wed May 14, 2014 12:18 pm
Posts: 317
@celauran yes i borrowed the example from there itself actually :) , i will try using the render method and see what happens.

Thank you.
Gautam.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group