pug-php / pug

Pug template engine for PHP
https://www.phug-lang.com
MIT License
391 stars 42 forks source link

Getting error: Fatal error: Maximum function nesting level of '100' reached, aborting! #87

Closed dzpt closed 8 years ago

dzpt commented 8 years ago

I used extends only 3 levels and found out using this template engine caused above error. I can expand the limit but will it cost more memory?

kylekatarnls commented 8 years ago

Yes 100 nesting levels may not be enough to handle too nested layouts, mixins, or interpolations.

But I have many websites with more than 3 extends levels. It probably depends on blocks too.

Pug compilation consume more memory than many templates engines closer to the HTML syntax such as Blade or Twig.

Remember, templates of any engine in any way should not be compiled on the fly in production. In production, you should pre-compile all your templates during the deploymen, then, use the cache to render templates with pre-compiled templates.

With, the cache, you consume much less memory.

Also note that nesting level does not impact memory, nesting level and memory limit are two settings you can edit regardless. On the countrary, a code too flat with less methods and functions will need more differents variables and will free memory later.