In Grails we often use Grails Scaffolding Templates using defscaffold = true in our Controller which automatically creates CRUD operations. Scaffolding uses the templates for code generation which can be installed by this command:-

grails install-templates

The install-templates command will copy the templates Grails uses to generate code. Templates are saved to the application’s src/templates directory. The templates directories include these sub-directories:


The artifacts directory contains the templates used by the create commands. The scaffolding directory contains templates used by the generate commands. The war directory contains the web.xml template used to generate the deployment descriptor.

When we modify the templates under Scaffolding directory the changes are applied to all domain’s CRUD screens. If we want to make some changes only in the particular Controller/View we can use the commands below:-

grails generate-controller "Fully-qualified-domainclass-name"
grails generate-views "Fully-qualified-domainclass-name"

The generate-controller command generates just the controller that implements CRUD for the given domain class.

The generate-views command generates just the GSP views that implement CRUD for the given domain class.

Once the Controller/View is generated we can modify it as per out requirement. The hierarchy which is created when using install-template command is :-

|– artifacts
| |—- Controller.groovy
| |—- DomainClass.groovy
| |—- Script.groovy
| |—- Service.groovy
| |—- TagLib.groovy
| |—- Tests.groovy
| |—- WebTest.groovy
|– scaffolding
| |—- Controller.groovy
| |—- create.gsp
| |—- edit.gsp
| |—- list.gsp
| |—- renderEditor.template
| |—- show.gsp
|– war
|—- web.xml

In the Controller.groovy(Scaffolding) we can find all the basic actions we would expect from the scaffolded controllers. This file is used when generate-controller command is invoked.

Next are the GSP files, create.gsp, edit.gsp, list.gsp and show.gsp. These are used to render the GSP markup required for your CRUD views. These files are used when generate-views command is invoked.

renderEditor.template file is used when rendering the HTML forms. It is used for a translation of a type like Date or byte[] to their according form elements like a date picker or a file upload button.

That was all about Grails Scaffolding templates.
Thanks 🙂