RE: [SMARTY] generating php

From: Date: Sat, 08 Jun 2002 19:02:06 +0000
Subject: RE: [SMARTY] generating php
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4701@lists.php.net to get a copy of this message
Why don't you use PHP to generate a config file based on what the user enables/disables? Then write a template that picks up the config and produces php conditionally based on the config. Gary -----Original Message----- From: Travis Low [mailto:travis@dawnstar.org] Sent: Saturday, June 08, 2002 12:54 PM To: smarty-general@lists.php.net Subject: Re: [SMARTY] generating php Well, sure, that's about what I did. But the application requires Smarty anyway, so I figured, why not use Smarty for the installer as well? It's a lot cleaner-looking, and also opens up the possibility of doing MORE than just replacing strings in a file. For example, I could ask the user if they wanted to disable this or enable that, and it would be handled with Smarty if statements that would emit this or that PHP code. Make sense? cheers, Travis Monte Ohrt wrote: > If you're just looking to search/replace some strings in a file, > Smarty > would be way overkill. You might be able to get a few ideas from it's > parser, but more likely you can do everything you need with preg_replace(). > > Travis Low wrote: > >> It's for an application installer. I needed to replace one or two >> include paths in a php file. Smarty seemed ideal for the job, but I >> got a zillion errors. Worked great with the .ini file, though. >> >> I tried adjusting the $php_handling, to no avail. I already use {{ >> and }} because it's easier on my eyes. I ended up using str_replace( >> "%%doowah%%", "the actual doowah", $the_string ). Call it primitive >> templating. >> >> Here's a preview version: >> <http://dawnstar.org/willow-installer.tgz>. >> Extract under your webroot somewhere, then point your browser to: >> <http://yourserver/under/your/webroot/somewhere/willow-installer/install >. >> Should work, but not guaranteed yet (couple more things to do, should >> finish tonight). >> >> cheers, >> >> Travis >> >> Martijn van Zal wrote: >> >>> Hahahaha, Let me get this straight.... >>> >>> U write a program using PHP, you combine this with a template engine >>> which produces PHP code, with the purpose of let that produced PHP >>> code produce PHP code? >>> >>> Seems a little complicated to me, and I'm very curious why you wan't >>> to use it. But it seems possible to me. >>> >>> I think you have to adjust the $php_handling variable to >>> SMARTY_PHP_PASSTHRU, and you might want to change the delimiter >>> tags, because { and } are not really practical. Maybe {{ and }} is >>> better. >>> >>> Let us know if it worked out, I'm very curious. >>> >>> Greets, >>> >>> ____________________________________________ >>> Martijn van Zal GFXartist network >>> Technical manager >>> >>> Mail: Martijn@gfxartist.com >>> Icq: 8213621 >>> >>> -----Original Message----- >>> From: Travis Low [mailto:travis@dawnstar.org] Sent: zaterdag 8 juni >>> 2002 5:10 >>> To: smarty-general@lists.php.net >>> Subject: [SMARTY] generating php >>> >>> Anyone out there using Smarty to generate PHP code? >>> >>> I don't think it's possible, but I wanted to check. >>> >>> cheers, >>> >>> Travis >>> >> >> > > > -- Travis Low <mailto:travis@dawnstar.org> <http://dawnstar.org/travis> -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

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