also optimize template filename resolving #321