lib/template: simple but efficient template system

Signed-off-by: Jean Privat <jean@pryen.org>