Fix conditional statements in template