F3 Template Language not working for me

194 views
Skip to first unread message

PROMETHEUS X

unread,
Mar 24, 2017, 8:30:20 PM3/24/17
to Fat-Free Framework

The following code does not work for me:
   $f3->set('name','world');
          echo \Template::instance()->render('template.htm');
 <p>Hello, {{ @name }}!</p>
But this code does:
$f3->set('name','world');
        $view=new View;
        echo $view->render('template.htm');
<p>Hello, <?php echo $name; ?>!</p>

Does anyone have an idea why? Note: I have the html markup in the template.php file, and the php code is in index.html.
All of my routes are working, for some reason when I use {{ @name }} it is not being recognized as it should be an instead it is 
being written verbatim to the browser window "Hello, {{ @name }}!"
ButF

PROMETHEUS X

unread,
Mar 24, 2017, 10:19:49 PM3/24/17
to Fat-Free Framework

PROMETHEUS X

unread,
Mar 24, 2017, 10:22:01 PM3/24/17
to Fat-Free Framework
I also have DEBUG=3 in an ini file and it is not giving the most verbose error reports. It's showing what DEBUG=2 is supposed to be showing. Furthermore, there was no tmp directory installed when I installed F3 3.6.0 via composer.

ikkez

unread,
Mar 25, 2017, 10:00:09 AM3/25/17
to Fat-Free Framework
set the UI var to the directory where your templates are.

PROMETHEUS X

unread,
Mar 25, 2017, 10:31:12 AM3/25/17
to Fat-Free Framework
Thanks for replying. I do believe that I have the UI variable set to my temple location. I have that in the config.ini file. I have set up a repo on guthub here:

If you could look at it that's be great. I think it's easier this way. I should have just posed a link to the repo in the beginning.

ikkez

unread,
Mar 25, 2017, 5:05:40 PM3/25/17
to Fat-Free Framework
The View engine is only a raw php renderer. So tokens like {{ @name }} can only be resolved with the Preview or Template engine.
Wehn you say, using the Template engine "does not work", what does that mean (error, white screen, unresolved variable, escaped html)?

PROMETHEUS X

unread,
Mar 25, 2017, 9:29:08 PM3/25/17
to Fat-Free Framework

ved

unread,
Mar 25, 2017, 10:46:38 PM3/25/17
to Fat-Free Framework
Did you create and define your TEMP folder and variable?

bcosca

unread,
Mar 25, 2017, 10:49:07 PM3/25/17
to Fat-Free Framework
The answer is right in front of you: create a tmp/ folder with the correct permissions. How much more verbose do you want it to be?

PROMETHEUS X

unread,
Mar 25, 2017, 10:52:01 PM3/25/17
to Fat-Free Framework
No, is there documentation on the F3 site that covers that? I created a Views folder but I take it that is not the same thing. My repo is up on GitHub, and here is the link to the folder where I have my view folder and the template.html file I reference.

PROMETHEUS X

unread,
Mar 25, 2017, 10:57:30 PM3/25/17
to Fat-Free Framework
Okay. I thought that the tmp folder was supposed to be generated when I installed F3 via composer though. Thank you everyone for being patient and trying to help me figure this out. Have a good day/night whatever it is wherever you are.

ved

unread,
Mar 25, 2017, 10:59:44 PM3/25/17
to Fat-Free Framework

GauravK

unread,
Mar 28, 2017, 9:20:12 AM3/28/17
to f3-fra...@googlegroups.com
I'm having the same problem. I have a git repo here https://github.com/gauravkeerthi/reallymeh

Here's the issue:
1. I created a /tmp folder and did the CHMOD 777 on the tmp folder (successful). I also have this line in my index.php :  $f3->set('TEMP', 'tmp/');
2. I can use normal php tags <?= $var ?> but cannot use {{ @var }} references in the html. When I use {{ @var }} the html output is exactly that ("{{ @var }}") which is obviously wrong.

What am I doing wrong?

On Sunday, 26 March 2017 10:59:44 UTC+8, ved wrote:

ved

unread,
Mar 28, 2017, 9:29:50 AM3/28/17
to Fat-Free Framework
@GauravK, you're using the View class instead of the Template or Preview classes. The View class doesn't support curly braces syntax.

Replace your "View::instance()" with "Template::instance()" and it should work.

GauravK

unread,
Mar 28, 2017, 9:52:41 AM3/28/17
to Fat-Free Framework
Thanks @ved!
Reply all
Reply to author
Forward
0 new messages