refactor template support like db/sql (auto-register)