Template code on database vs file

72 views
Skip to first unread message

Fed X

unread,
Sep 17, 2018, 9:33:26 PM9/17/18
to Fat-Free Framework
Hi,
1. is there a way for F3 to use templates stored in a database vs a file? I am doing that with Smarty and was wondering if F3 has similar capability.
2. did anybody compare F3 template engine and Smarty performance?

Thanks a lot,
Fed

bcosca

unread,
Sep 17, 2018, 10:59:43 PM9/17/18
to Fat-Free Framework
F3 does not force/require you to use its template engine.

Having said that, you can certainly use templates stored in a database. However, you lose debugging capabilities because you have to use resolve() which uses eval() internally - which might not be in accordance with your development taste. Files are still the best way to go because of enhanced debugging and PHP's internal caching capabilities.

As far as performance is concerned, the only time benchmarking makes sense is during the template compilation, i.e. conversion to PHP code. That process though is a one-time activity. It doesn't matter then if one template engine is faster than the other by a few msecs.

All that on the table, F3 has three template engines for you to choose from. You can use Twig, Smarty, or whatever. After all, programming convenience and readability are the best reasons for choosing one over the other. Benchmarking template engines is for nitpickers.

Fed X

unread,
Sep 18, 2018, 2:55:30 PM9/18/18
to Fat-Free Framework
1. I do know I can use different other engines even though my question was about its engine or  the Template:: class.
2. I read a few articles in the past and they actually show even an order of magnitude difference on cached execution as well, not just the compilation process. On "hello world" I am not concerned about speed but on a busy site an order of magnitude does make a difference.
Thanks,
Fed

ikkez

unread,
Sep 19, 2018, 6:09:06 AM9/19/18
to Fat-Free Framework
Try to use this one:

$html = $template->resolve( $template->parse( $templateFromDatabase ) );

Conversation Exchange - FB

unread,
Sep 19, 2018, 8:31:58 AM9/19/18
to ikkez via Fat-Free Framework
Thanks a lot Ikkez

--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Fat-Free Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/f3-framework/IvLME_yIQIA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to f3-framework...@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.
To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/66a712ee-b658-41df-8b15-04f5497dbf77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages