Adding conditional before performing logic to replace template tag.