Reputation: 1292
In the following what is a template
? Where do I create it and how is it used?
def RenderDemo = {
//Render text to response
render "hellooooo"
//Render text for specified content type/ encoding
render (text: "<strong><h1><marquee>Akshay</marquee></h1></strong>" , contentType: "text/html")
//Render a Template to the response for the specified model...
def theShining = [title: "The Shining" , auther : "king"]
render(template: "RenderDemo" , model: [book : theShining])
}
Upvotes: 1
Views: 724
Reputation: 24776
A template is a partial GSP or a fragment of a GSP. It's intended to be reused. Just like any other GSP it belongs in the grails-app/views/
directory structure. All templates have a filename that begins with an underscore _
. So in your example the template would be: grails-app/views/render/_renderDemo.gsp
.
I highly recommend you read the official documentation on views and templates that explains why you would use a template as well as providing you with even more details about templates in general.
Upvotes: 3