Template Inheritance

91 views
Skip to first unread message

Roman Alekseev

unread,
Apr 16, 2017, 1:31:23 AM4/16/17
to Fat-Free Framework
Is it possible to implement Template Inheritance feature like in Twig for F3 internel temlate engine?

ikkez

unread,
Apr 16, 2017, 8:28:00 AM4/16/17
to f3-fra...@googlegroups.com
probably not all are used to Twig, so please specifiy your request and give us a little more details please. F3 template engine has includes,.. does that fit your needs?

Roman Alekseev

unread,
Apr 17, 2017, 12:21:51 AM4/17/17
to Fat-Free Framework
includes is OK. But I mean extends - very useful technique for making reusable HTML layouts. It is much more flexible than alternative techniques, such as “including” common elements of a page (like a header and footer file).

bcosca

unread,
Apr 17, 2017, 12:27:27 AM4/17/17
to Fat-Free Framework
Short answer: Yes.

Long answer: RTFM.

xfra35

unread,
Apr 17, 2017, 6:45:27 AM4/17/17
to Fat-Free Framework
No F3 doesn't natively implement the concept of template inheritance.

But I don't think it would be too hard (except maybe for the parent() directive) to implement it yourself via the powerful template extension feature.

The result could look like this:

<extends href="base.html">

 
<block name="title">Index</block>

 
<block name="content">
   
<h1>Index</h1>
   
<p class="important">
      Welcome on my awesome homepage
   
</p>
 
</block>

</extends>

You can find some examples on how to implement tag handlers in the core itself or in ikkez FooForms plugin.

Roman Alekseev

unread,
Apr 19, 2017, 7:55:30 AM4/19/17
to Fat-Free Framework
Is there any plans to make it to work in F3 out of the box?

понедельник, 17 апреля 2017 г., 13:45:27 UTC+3 пользователь xfra35 написал:

ved

unread,
Apr 19, 2017, 8:22:27 AM4/19/17
to Fat-Free Framework
AFAIK, F3 works fine with any template engine so why not just use Twig in the first place?
Reply all
Reply to author
Forward
0 new messages