applyDefines didn't iterate all template tree