|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
richardward Smarty n00b
Joined: 27 Oct 2011 Posts: 3
|
Posted: Mon Oct 31, 2011 10:05 am Post subject: SmartyCompilerException |
|
|
We have an error handler which, upon an exception or php error, displays a traceback including the relevant lines from the php source files (the line from the stack trace, highlighted, and a few lines from before and after). This tends to make debugging a little easier.
We'd like it to print out template source in a similar way when smarty throws a SmartyCompilerException. I've modified smarty a little so that it passes the Smarty_Internal_TemplateCompilerBase to the SmartyCompilerException constructor. In the constructor I can then store $compiler->lex->taglineno and $compiler->parser->template->source->content and use them to print out the relevant source in the exception handler.
There are two problems with this approach. One, I'm passing a large chunk of data around in the exception, which doesn't seem great. The other is that $taglineno is the line in the current block, not necessarily the line in the current file. If I don't pass content around in the exception then I need to use the filename to read in the source at the correct point - and for that I need the correct line number.
Anyone know of a way to get the real line number, or can anyone suggest an alternative method of doing what I'm trying to do?
Thanks. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Nov 01, 2011 12:24 pm Post subject: |
|
|
Template source code trace back will be an standard feature in the next major release 3.2 which we are currently working on.
You should wait for that, because the trace back on template inheritance blocks did require a couple of internal changes.
Currently we have not yet a firm release date, but it should not be too far away. |
|
Back to top |
|
richardward Smarty n00b
Joined: 27 Oct 2011 Posts: 3
|
Posted: Tue Nov 01, 2011 12:30 pm Post subject: |
|
|
Good to know.
For the time being I'll make do with just highlighting the relevant line from $compiler->parser->template->source->content.
Is there a mailing list or bug track issue discussing this new feature? I'd be vaguely interested in knowing what is coming.
Thanks. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|