I have some javascripts loaded from google to speed up my sites - anyone who has used the Yahoo YSlow plugin for FireBug will be familiar with the "F" rating for content delivery networks (CDN) score. But I have a developer on my team who works offline and wants to be able to develop locally without having to constantly modify all the view.yml files (and there are a few!) for each app.
So, although it would be nice to be able to specify an environment in the view.yml the same way you can in the settings.yml, some folks forget that you can put PHP code in your view.yml to be evaluated at runtime (or at least read from the cache at runtime!).
So, this is how we manage to serve google's minified high speed Javascript libraries in the "live" environment but use local copies elsewhere:
default:
javascripts:
- <?php echo (strpos(SF_ENVIRONMENT,"live")!==false?'http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js':'/js/prototype').PHP_EOL ?>
- <?php echo (strpos(SF_ENVIRONMENT,"live")!==false?'http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/scriptaculous.js?load=effects':'/js/scriptaculous/scriptaculous.js?load=effects').PHP_EOL ?>
Damn, that was easy, wasn't it?
:-)
Comments are not available for this entry.



Avatar



