Fix crash when no global context is supplied, no handler context is supplied, and a layout template is being used