With this template #ifeq can be used in a way such that it does not strip spaces and newlines from the "then" and "else" part.
{{ifeq|x|x| p | q }}
{{ifeq|x|y| p | q }}