Support control structures inside @if (#13841)

This change allows the use of control structures such as @if
inside an @if in custom functions.

Change-Id: Idf3119d5a884801e0ddaff540e3acdbedcf82c0e