Issue 19890, optimize ifchanged tag to render contents once.

The contents was rendered twice when the classic style
`{% ifchanged %}output{% endifchanged %}` was used.
The output is kept in a local variable now.