Smart template-path building