Update templates.php

Condition fixes.