Refactor conditional for text directive