Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

SmartyCompilerException

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
richardward
Smarty n00b


Joined: 27 Oct 2011
Posts: 3

PostPosted: Mon Oct 31, 2011 10:05 am    Post subject: SmartyCompilerException Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Nov 01, 2011 12:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
richardward
Smarty n00b


Joined: 27 Oct 2011
Posts: 3

PostPosted: Tue Nov 01, 2011 12:30 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP