Re: Bugfix for comments
| From: | Andrei Zmievski | Date: | Tue, 25 Sep 2001 21:34:49 +0000 |
| Subject: | Re: Bugfix for comments | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1547@lists.php.net to get a copy of this message | ||
Patched in, thanks. I tried to find a faster method, but this will do
for now, as it's quite simple too.
On Sat, 22 Sep 2001, Anders Janson wrote:
> The new code (v 1.4.5) that allows commenting out Smarty tags is
> a little buggy. Line numbering does not always work. Try this short
> template:
>
> {bad tag on line 1}
> {* line 2
> line 3
> line 4 *}
>
> The warning is reported for line 3! Actually, the more lines you
> have in comments appearing after a bugged tag, the more offset you
> get.
>
> FIX:
>
> 1) In Smarty_compiler.class.php, function _compile_file(), replace
> the following lines:
>
> /* Annihilate the comments. */
>
> if (preg_match_all("!{$ldq}\*.*?\*{$rdq}!s", $template_source,
> $match)) {
> foreach ($match[0] as $comment)
> $this->_current_line_no += substr_count($comment, "\n");
> $template_source = preg_replace("!{$ldq}\*.*?\*{$rdq}!s",
> '', $template_source);
> }
>
> .. with the following lines :
> /* Annihilate the comments. */
>
> $template_source = preg_replace("!({$ldq})(\*.*?\*)({$rdq})!se",
> "'\\1*'.str_repeat(\"\n\",substr_count('\\2',
> \"\n\")) .'*\\3'",
> $template_source );
>
>
> 2) add the following (old code from v1.4.4) at the top of function
> _compile_tag() :
>
> /* Matched comment. */
> if ($template_tag{0} == '*' && $template_tag{strlen($template_tag)-
> 1} == '*')
> return '';
>
> The replacement code in step 1 wipes out everything within the comment
> tag, but keeps the linebreaks. Same number of lines, and the comment
> is still left as a tag to handle. Step 2 then takes care of the comment
> tag (now empty) just the way it was before 1.4.5.
>
>
> /Anders
>
>
>
>
>
>
>
> ---
> You are currently subscribed to smarty as: andrei@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
-Andrei
Nobody tried to design Windows - it just grew in random
directions without any kind of thought behind it.