Add support for calling a function before rendering a template