Re-fix <template if>, added test for <template repeat if>

R=arv
BUG=

Review URL: https://codereview.appspot.com/10290043