How can I tell what DEFs are generating certain parts of my skin/template output?

In Foswiki 1.1+, the TRACE mode of lib/Foswiki/Templates.pm adds HTML comments at the beginning and end of every %TMPL:P% statement with the name of the DEF that was P'd. This can aid debugging skins/templates by giving you the name of the DEF which produced some output.

ALERT! Warning: Do not enable Templates.pm TRACE mode on a live production site

Enabling TRACE mode in lib/Foswiki/Templates.pm requires modification of that file. This feature should probably be made more accessible, however it is worth noting that enabling this feature will break your site - it will produce invalid HTML (comments where there shouldn't be) and the output will look broken in the web browser.

So it is designed for annotating the raw HTML source.

Procedure

  • Establish a parallel (non-public/production) version of your site
  • Modify lib/Foswiki/Templates.pm: Look for the line which reads use constant TRACE => 0; and change it to read use constant TRACE => 1; (near the top)
  • If you are running persistent perl like fastcgi or mod_perl: restart apache
  • View the HTML output from the page of interest; there should be HTML comments annotating the output as described above.
-- PaulHarvey - 17 Dec 2010

Support.FAQForm edit

TopicClassification FrequentlyAskedQuestion
Subject Development, Templates
Topic Summary Explains how to enable TRACE mode for debugging templates
Extension
Interested Parties
Related Topics
Topic revision: r3 - 27 Dec 2011, ArthurClemens - This page was cached on 05 Jul 2017 - 13:57.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License