Volt templating (Phalcon) - What is better between "partial" and "include" to use in a loop?

1.5k Views Asked by At

I see there are 2 options to include a "partial" template within a template (using Volt, Phalcon PHP framework) Documentation: https://docs.phalconphp.com/en/latest/reference/volt.html#view-integration

What is better between "partial" and "include" to use in a loop (about 100x)? In terms of performance / memory usage?

Thank you.

1

There are 1 best solutions below

0
On

@honerlawd answered my question in a comment.

It is better to use partial in a loop.

Basically partial is better for what you are trying to do. Include copies the code into the file on compile. So every time you change the variables it would have to recompile the template and insert it. Partial compiles to a function $this->partial() and is executed by the php interpreter which is faster in the context you are trying to use it.