Added support for nested IF's within templates.