1

Does Craft parse the contents of a false/negative/empty conditional statement? So would you take a performance hit if you had a big chunk of code inside a conditonal that was false?

{% set foo = "foo" %}
{% if foo == foo %}Small code {% else %} MASSIVE CODE{% endif %}
Mark
  • 731
  • 3
  • 11

1 Answers1

3

Yes, Twig will parse it all down to PHP before running it. It stores the rendered PHP in a /storage/runtime/compiled_templates/ file.

No, Craft will not run anything inside the conditional if it's false. At that point, it's simply processing exactly as normal PHP would.

So no, you shouldn't be notably penalized for anything inside a falsey if statement.

Lindsey D
  • 23,974
  • 5
  • 53
  • 110