Difference between a View and a Template

93 views
Skip to first unread message

Alexandre Plennevaux

unread,
Jun 27, 2017, 4:35:17 PM6/27/17
to Fat-Free Framework
What are the differences between using a View and a Template in FatFree ?

Sascha

unread,
Jun 27, 2017, 4:39:12 PM6/27/17
to Fat-Free Framework
Check the docs. Basically, View allows you to use pure PHP in your templates. The Template class provides its own template engine. Seehttps://fatfreeframework.com/3.6/views-and-templates

Alexandre Plennevaux

unread,
Jun 27, 2017, 4:47:56 PM6/27/17
to Fat-Free Framework
I checked that exact page and read it twice, but the two constructs seem so close to each other, I don't see the point in the distinction, especially for a microframework. 

Thank you for taking the time to reply.

ved

unread,
Jun 27, 2017, 5:59:55 PM6/27/17
to Fat-Free Framework
So you can't see a distinction between these two as Views? Maybe you should read the docs a third time :)

Examples of multiple languages using the F3 template engine:

<h1>{{ @love }}</h1>
<p>
    {{ @today,time() | format }}.<br />
    {{ @money,365.25 | format }}<br />
    {{ @pi, 3.1415 | format }}
</p>

And the longer version that utilizes PHP as a template engine:

<?php $f3=Base::instance(); ?>
<h1><?php echo $f3->get('love'); ?></h1>
<p>
    <?php echo $f3->get('today',time()); ?>.<br />
    <?php echo $f3->get('money',365.25); ?><br />
    <?php echo $f3->get('pi', 3.1415); ?>
</p>

Alexandre Plennevaux

unread,
Jun 27, 2017, 6:26:21 PM6/27/17
to f3-fra...@googlegroups.com
both your replies makes it clear, but the documentation on that page does not:

It uses View only at the beginning, then moves on to using "template" all the time.  It was unclear to me if i should instantiate Views or Templates in my controllers. I guess the documentation assumed I knew something I didn't. 

I'll just commit a slight change to make it more obvious.

Thank you for your time.

Summer White

unread,
Jul 4, 2017, 11:51:13 PM7/4/17
to Fat-Free Framework
The documentation sometimes does require you to understand the inheritance chain and to read the parent classes more closely.

I had major trouble learning Jig because I wasn't looking at the parent class Active Cursor which had the most helpful information in it.
Reply all
Reply to author
Forward
0 new messages