Add template(''); support for gf
Refactor gf to have a more resilient fallback