maint: Some refactoring to allow reuse.

* luatpl.lua: Likewise. Add function luatpl(...)