vector
vector

Reputation: 7576

The difference between render(...) and g.render(...) in grails

I have the following bit in a controller:

            def myJSON = [

                    'form' : g.render(template: '/information/form', model:informationInstance)
            ]

            render myJSON as JSON

... and wonder what's the difference between and purpose of render() and g.render()?? And where does 'g' come from?

Upvotes: 2

Views: 608

Answers (1)

Gregg
Gregg

Reputation: 35874

The g is the namespace for the Grails tag library. It is automatically injected into controllers and views. In a controller, you access it as g.XXX() rather than <g:XXX />. There really is no difference in how they function under the covers except with how the controller triggers its response.

Upvotes: 4

Related Questions