Fixed wrong code replacement with if statements in the template engine.