PostgreSQL implementation of handlebars templating