Re: [SMARTY-DEV] Error reporting info in compiled templates
[email protected] ("Daniel BODEA")
| Newsgroups | php.smarty.dev |
|---|---|
| Message-ID | <036a01c48b75$d6b95080$25c0a8c0@ghotix> |
Sure. Our system manages data that is provided in a raw form to designers that create as many templates as they wish and have the freedom to include any piece of info anywhere and in any template. We don't provide the templates with a fixed set of data that they can display but rather provide Smarty plug-ins that the designers can use to retrieve the data that they want to display and then work with it using Smarty modifiers, etc. We can have for instance a plug-in named "article" that can be invoked by a designer using certain parameters in order to fill in a Smarty variable with the contents of a certain article or even a list of articles and further on the possibilities are limitless. Now lets say this plug-in needs to report an error to the designer so that he can know the exact location where the error occurred (template name, plug-in name and line number). Except using backtraces or complicated compiler plug-ins, I couldn't find any Smarty feature that could help in this situation. This information should be ideally handled by the trigger_error method so that the plug-in system need only call this method with the error message but a first step would be to make Smarty aware of the correspondence between the compiled templates that it includes and the original designer templates because as of now, once a template is compiled, any corresponding line numbers or template names are lost. If this information were available, the plug-in system could report the exact location of the error and the trigger_error method could also evolve to report the location in just about any situation. Daniel ----- Original Message ----- From: "Monte Ohrt" <[email protected]> To: "Daniel BODEA" <[email protected]> Cc: <[email protected]> Sent: Thursday, August 26, 2004 3:38 PM Subject: Re: [SMARTY-DEV] Error reporting info in compiled templates > Can you give a specific example of how this would work and what this > would accomplish? > > Thanks > Monte > > Daniel BODEA wrote: > > >Greetings, > > > >We are using Smarty in a system that needs a little more than a simple > >template engine and the plug-ins system is the one that allows for that. We > >basically provide plug-ins for data retrieval inside the templates and let > >designers organize their templates the way they see fit and put in the > >content of their choice. > > > >What I believe is missing from Smarty right now though (that is if I'm not > >mistaken), is the debugging info inside the compiled templates that we'd use > >for instance to report exact errors to the designers. A data retrieval > >plug-in that needs to report an error to the designer can currently either > >use Smarty's trigger_error method that doesn't tell the designer much or > >play around with backtraces and Smarty private variables to try to figure > >out the template name, the line number and the plug-in name that the > >designer needs to track down the problem, and all this time hoping that you > >don't stumble upon PHP bugs in backtraces and the like. Needless to say this > >solution is neither scalable nor does it guarantee consistency with future > >versions of Smarty. > > > >The solution would be to track debug info in compiled templates either as > >PHP statements that fill in variables or as PHP comments with special > >prefixes that don't add any more processing weight to the templates and can > >be easily searched for in case error reporting is needed. > > > >This is just the incentive of the idea but I'd first like to know if such a > >system already exists or if anyone is already working on something related > >and also if the project's coordinators would be interested in such a thing. > > > >Daniel > > > > > > > >