I have different kinds of html emails i want to send to my users, but each email uses the same layout (emailLayout.gsp). I need to render this emails (gsp) to string, to send them via an email method.
Using this code this does work, but i need it working with the groovyPageRenderer.render() method, because i need to send emails in a grails filter or service (the above 2 outcommented examples doesn't work):
//def emailContent = groovyPageRenderer.render(view: '/email/emailConfirmation', model: [userInstance: userInstance])
//def emailContent = g.render(view: "/email/emailConfirmation", model: [userInstance: userInstance])
def emailContent = g.include(view: "email/emailConfirmation.gsp", model: [userInstance: userInstance])
Using groovyPageRenderer doesn't include my layout html, only the emailConfirmation.gsp content gets rendered. So header and footer from my emailLayout.gsp is missing. Why doesn't groovyPageRenderer.render() renders the full gsp WITH layout?
Thanks for your help!