From c14f28ef89ee7a78b6d4c07909a0ae7cd6624cba Mon Sep 17 00:00:00 2001 From: Lari Hotari Date: Thu, 2 Sep 2010 11:42:30 +0300 Subject: [PATCH] Basic documentation for GSP debugging (showSource, debugTemplates) GRAILS-6257, GRAILS-5163 --- src/guide/6.2.7 GSP Debugging.gdoc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/guide/6.2.7 GSP Debugging.gdoc diff --git a/src/guide/6.2.7 GSP Debugging.gdoc b/src/guide/6.2.7 GSP Debugging.gdoc new file mode 100644 index 00000000000..e7b79cfffa3 --- /dev/null +++ b/src/guide/6.2.7 GSP Debugging.gdoc @@ -0,0 +1,29 @@ +h4. Viewing the generated source code + + * Adding "?showSource=true" or "&showSource=true" to the url shows the generated groovy source code for the view instead of rendering it. It won't show the source code of included templates. This only works in development mode + * The saving of all generated source code can be activated by setting the property "grails.views.gsp.keepgenerateddir" (in Config.groovy) . It should point to a directory that's existing and writable. + * During "grails war" gsp pre-compilation, the generated source code is stored in grails.project.work.dir/gspcompile (usually in ~/.grails/(grails_version)/projects/(project name)/gspcompile). + +h4. Debugging GSP code with a debugger + + * "Debugging GSP in STS":http://contraptionsforprogramming.blogspot.com/2010/08/debuggable-gsps-in-springsource-tool.html + +h4. Viewing information about templates used to render a single url + +GSP templates are re-used in large web applications by using the g:render taglib. A lot of small templates can be used to render a single page. +It might be hard to find out what gsp template actually renders the html seen in the result. +The debug templates -feature adds html comments to the output. The comments contain debug information about gsp templates used to render the page. + +Usage is simple: append "?debugTemplates" or "&debugTemplates" to the url and view the source of the result in your browser. +"debugTemplates" is restricted to development mode. It won't work in production. + +Here is an example of comments added by debugTemplates : +{code} + +. +. +. + +{code} + +Each comment block has a unique id so that you can find the start & end of each template call.