Re[2]: [SMARTY-DEV] Incorrect newline counters

From: Date: Sun, 30 May 2004 20:42:23 +0000
Subject: Re[2]: [SMARTY-DEV] Incorrect newline counters
References: 1 2  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2334@lists.php.net to get a copy of this message
CR after ?> is not a real problem. We may always use "<?php\n?>" construction to fix it. My patch (attached before - have you seen this, or attachments are not shown in your client?) uses this method to sync line numbers. And even more - property $_additional_newline may not be used at all, in all cases (I also think it was a bad design to include its support from the beginning, but not sure). I think that we should not use \n after ?> at all - in all cases. Instead, use "<?php\n?>" in place of each \n in the template - it works fine. Newer versions of PHP do not fix \n eating after ?> tag and (I am almost sure) will not change this behavour in the future. All that I want is to include this patch in production version. Now I am finishing a book about PHP5, and one of its chapter describes Smarty. I cannot write about it before line numbers synchronization is fixed, and I am ready to help Smarty developers to fix it totally and forever. -- Best regards, Dmitry Koteroff. RA> Hi Dmitry, RA> this is a topic which has been raised before, but I am unable to find the RA> resolving email given at the time, so I will have to rely on my memory of RA> the situation. RA> Basically, the smarty templates are geared so the resulting output is the RA> same as the template, and is a higher priority than the compiled template RA> itself. RA> There is (or used to be at least) a problem where php would strip off RA> carriage returns/newlines following a closing php tag. This means that RA> everytime you call a template variable, you'd lose a line in your output. RA> Smarty counters this by adding an additional newline after the close of the RA> tag, so that the output returns the same as the template itself. RA> Now it could be that this situation has changed in recent releases of PHP, RA> or that my memory is slightly faulty (in which case one of the others is RA> more than welcome to step in and correct me), but I do know there is a good RA> reason that the compiled templates come out with different line numbers to RA> the template itself, and that this has been raised before, and answered, so RA> a more thorough check of the list archives should reveal the answer. RA> Regards, RA> -bok RA> At 05:39 AM 30/05/2004, you wrote: >>Hello. >> >>Smarty do not preserve line numbers while compiling the template. >>When an error occurs, PHP shows line number in compiled file, and >>it does not correspond line number in the source template. >> >>Example. If I have the following template: >> >>1 {t_block name="Title"}...{/t_block} >>2 {t_block name="Author"}...{/t_block} >>3 {t_block name="Text"} >>4 {strip} >>5 ss >>6 ddd >>7 {/strip} >>8 {$a} >> >>and $a is undefined, I get notice not in line 8, but in other. >>Resulting template contains: >>a) superfluous \n's - in the headder comments /* compiled from >> ...*/, and after plugins require_once's; >>b) insufficient spaces - {strip} processed incorrectly, it glues >> its body, replacing \n by '', but not by <?php\n?> >> >>What do you thing about all that? If I write the patch which will >>correct line numbers, will you include it in production version? >> >>-- >>Best regards, >> Dmitry Koteroff. >> >>-- >>Smarty Development Mailing List (http://smarty.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.dev (#2334) next »