Rendering a grails template outside of the application -
i have flexibility render templates emails , files not present underneath views/ directory or anywhere in application.
the reason can package , deploy versions of templates independently of main application.
so have template '_backup_email.gsp' defined under 'views/emails/'.
if following:
render groovypagerenderer.render(template: "/emails/backup_email", model: [servergroup: servergroup])
then renders fine.
if copy template 'c:/templates/emails/_backup_email.gsp' execute following:
render groovypagerenderer.render(template: "c:/templates/emails/backup_email", model: [servergroup: servergroup])
i blank screen.
i missing here.
how using property instead of hard coded paths templates?
you can start application -dtemplatefolder=/home/user/grails/templates.
i keep templates plain text files content of mails etc. can include rendered/merged templates in gsps reside in usual grails folders.
since using grails, must have access string template engine of groovy can use merge templates data.
string template engine documented here
http://www.groovy-lang.org/templating.html
i hope helps.
Comments
Post a Comment