Re: [SMARTY] start end tags patch
| From: | Monte Ohrt | Date: | Tue, 02 Jul 2002 05:11:52 +0000 |
| Subject: | Re: [SMARTY] start end tags patch | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5158@lists.php.net to get a copy of this message | ||
Exactly what is this for?
Pupeno wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
This files are a simple code that in case there's a start end tag pair, just what is between this tags will be procesed, if there's no tag, it will be procesed as usual, if there's only one tag, an error is generated (in the way I see other errors are triggered in Smarty).
The start and end tag are not case sensitive.
This patch is for current (200207012314-4UTM) cvs.
Feel free to modify it in any way or ask me to modify it.
- -- Pupeno: pupeno@pupeno.com
http://www.pupeno.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9IRrjLr8z5XzmSDQRAn5JAKCvi5R84qIU9qxeWFlLivrxfgMolwCfWzJR
nYqXSp7ssvHu3rJBKCtVA8o=
=6wzE
-----END PGP SIGNATURE-----
------------------------------------------------------------------------
Index: Smarty_Compiler.class.php
===================================================================
RCS file: /repository/smarty/Smarty_Compiler.class.php,v
retrieving revision 1.119
diff -c -r1.119 Smarty_Compiler.class.php
*** Smarty_Compiler.class.php 27 Jun 2002 14:25:25 -0000 1.119
--- Smarty_Compiler.class.php 2 Jul 2002 03:14:26 -0000
***************
*** 72,77 ****
--- 72,84 ----
$this->_current_line_no = 1;
$ldq = preg_quote($this->left_delimiter, '!');
$rdq = preg_quote($this->right_delimiter, '!');
+ + // if there are start and end tags, clean everything else
+ if(preg_match_all("/.*{$ldq}start{$rdq}.*{$ldq}end{$rdq}.*/s", $template_source, $matches)){
+ $template_source = preg_replace("/.*{$ldq}start{$rdq}(.*){$ldq}end{$rdq}.*/s", "\\1", $template_source);
+ } else if(preg_match_all("/{$ldq}(start|end){$rdq}/s", $template_source, $matches)){
+ $this->_syntax_error("The start/end tag pair is not complete");
+ }
// run template source through prefilter functions
if (count($this->_plugins['prefilter']) > 0) {