add support for head.js
Fix template try bug