开发者

Grails: Debugging scaffolding template

开发者 https://www.devze.com 2022-12-28 08:01 出处:网络
is there a way to debug the scaffolding template (generated in /src/template/scaffolding). Not to debug the view gsp files, but the template itself. I guess I could put some co开发者_Python百科mments.

is there a way to debug the scaffolding template (generated in /src/template/scaffolding). Not to debug the view gsp files, but the template itself. I guess I could put some co开发者_Python百科mments.. other than that..


Normally you should not have to "debug" the template as the templates work rather well.

I am thinking you are looking for tracing the data flow to make your own modifications to the templates which will lead you to using print statements. Otherwise, you are looking at using the Page Renderer.

So, there are two options I would recommend:

  1. Print statements. This is your easy, tried and true, brute force approach. I have used it a year ago in early 2011 for a project and it works well. The downside is that it is non reusable (unless you leave your code commented out but that's a bit awkward). This allows you to step through the "guts" of the template system and see what happens. The framework cannot "hide" anything from you really, so you get a front-row seat at what happens.

  2. Use the grails.gsp.PageRenderer

This allows you to debug things at runtime, you can create proper tests, asserts, reusable components, the works. You are a little removed from the actual templates (as opposed to using print statements inside the templates).

Here is a link to the GRAILS Doc: Page Rendering Doc

Here is a link to an example on how to use them: Grails Goodness: Render GSP Views and...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号