ownlifeful has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Oh Wise Perlmonks,

I have inherited a large RequestTracker ( based on Mason ) codebase. There are so many components and subcomponents to this system. It is difficult to pinpoint which component emitted which chunk of HTML.

So I was thinking of writing a Mason handler that would put in HTML comments before and after the output from each component, so that it is simple to trace the output back to the originating component.

<!--- BEGIN navbar ---> <NAVBAR>...</NAVBAR> <!--- END navbar ---> <!--- BEGIN content ---> ... <!--- END content --->

Before I start, I would like to seek your collective wisdom. Has someone already done this? Any guidance on how to go about doing it?

Thanks,

Replies are listed 'Best First'.
Re: Tracin' Mason
by talexb (Chancellor) on Sep 15, 2022 at 15:45 UTC

    If you can do this in a handler, great! My approach would probably be more mundane -- I'd just add comments in the actual templates, so that by looking at the source code of a web page, I could figure out which templates were used.

    Because that information might be a security risk, I might wrap that in a function that doesn't show output that information in PROD.

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

      Adding comments to actual templates was my first thought too. But we are dealing with a system with literally thousands of components.

      I would disable the comments functionality when deploying the code to PROD, but in DEV this would definitely be a good feature to have, and one that Mason ought to support.

          .. literally thousands of components.

        Hmm .. that's taking components a little seriously. :) Thousands of components is a little mad. I'd still add comments to the obvious pieces -- at least to help you understand where they all are. As you get more familiar with everything, it should become easier.

        Alex / talexb / Toronto

        Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.