RE: [SMARTY-DEV] Trouble compiling tpl from resource plugin

From: Date: Tue, 16 Jul 2002 21:06:21 +0000
Subject: RE: [SMARTY-DEV] Trouble compiling tpl from resource plugin
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5345@lists.php.net to get a copy of this message
Er, maybe I'm totally wrong -- basename() works (PHP 4.2.1/Win32). But: filenames usually get the $template_dir prepended (on Win32, DIRECTORY_SEPARATOR is the backslash), and paths in the *compiled* templates are written using double quotes: $this->_smarty_include("file:e:\httpd\htdocs\default\smarty\templates\he ader.tpl", array('title' => "foo")); The \t (right after smarty) is the TAB escape sequence, causing basename() to fail.. So, shouldn't it work if the double quotes are replaced with single ones..? >Blagh. that should be "ignores double byte characters." > >>-----Original Message----- >>From: Gary Loescher [mailto:gary@loescher.org] >>Sent: Tuesday, July 16, 2002 11:44 AM >>To: Monte Ohrt >>Cc: Jason Sweat; smarty-dev@lists.php.net >>Subject: RE: [SMARTY-DEV] Trouble compiling tpl from >>resource plugin >> >> >>Well, I vote for urlencode. Basename only looks for >>slashes (\ and /) and double byte characters, >>according to the code. >>Gary >> >>>-----Original Message----- >>>From: Monte Ohrt [mailto:monte@ispi.net] >>>Sent: Tuesday, July 16, 2002 11:12 AM >>>To: gary@loescher.org >>>Cc: Jason Sweat; smarty-dev@lists.php.net >>>Subject: Re: [SMARTY-DEV] Trouble compiling tpl from >>>resource plugin >>> >>> >>>Using strpos, We are assuming that ":" is the only >>>character we're >>>looking for. Are there any other characters that >>>basename wouldn't >>>catch? In any event, urlencode is much faster and >>>covers everything. >>> >>>Gary Loescher wrote: >>>> Heh. I was just writing an email to suggest this >>>> same code. Great minds, Jason :) >>>> >>>> Looks like we're stuck with munged filenames >>>> again, or a performance hit. Personally, the >>>> filename doesn't bother me. I actually like >>>> being able to easily identify the resource >>>> used to get the template. In the "file:c:/foo.tpl" >>>> case, though, I guess that the price for >>>> using an absolute path would be funny-looking >>>> compiled template names. ;) Seems to me >>>> using an absolute path is a bad practice, anyway. >>>> >>>> Gary >>>> >>>> >>>>>-----Original Message----- >>>>>From: Jason Sweat [mailto:jsweat_php@yahoo.com] >>>>>Sent: Tuesday, July 16, 2002 10:36 AM >>>>>To: smarty-dev@lists.php.net; gary@loescher.org; >>>monte@ispi.net >>>>>Subject: Re: [SMARTY-DEV] Trouble compiling tpl from >>>>>resource plugin >>>>> >>>>> >>>>>What about this ? >>>>>if ($offset=strpos($string,':')) { >>>>> $offset++; >>>>>} >>>>>$match = substr($string,$offset); >>>>> >>>>> >>>>> >>>>>Well we may have to use urlencode instead of trying to >>>>>get the filename. >>>>>preg_match and preg_split are get what we want but are >>>>>much slower. >>>>> >>>>>repeated 100,000 times: >>>>> >>>>>urlencode(basename($string)); --> 2.920 >>>>>secs >>>>> >>>>>preg_match('![^:|/\\\\$]!',$string,$match); --> 7.627 >>>>>secs >>>>>explode(':',basename($string)); --> 5.436 secs >>>>> >>>>>The second two get it right, but they take much >>>>>longer. Unless there are >>>>>any other ideas? >>>>> >>>>>Monte >>>>> >>>>>__________________________________________________ >>>>>Do You Yahoo!? >>>>>Yahoo! Autos - Get free new car price quotes >>>>>http://autos.yahoo.com >>>>> >>>>>-- >>>>>Smarty Development Mailing List (http://smarty.php.net/) >>>>>To unsubscribe, visit: >>>>>http://www.php.net/unsub.php >>>>> >>>> >>>> >>> >>> >>> >>>-- >>>Monte Ohrt <monte@ispi.net> >>>Director of Technology, ispi Inc. >>> >> >>-- >>Smarty Development Mailing List (http://smarty.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php >> > >-- >Smarty Development Mailing List (http://smarty.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.smarty.general (#5345) next »