symfonyでGoogleMapsを使うページだけにAPI Keyを埋め込む
slot使えばできます。
layout.phpにスロット読み込む記述をして、
実際にJavascript書くテンプレートでスロットを定義してやればOK。
- layout.phpの一部
<head> <?php include_http_metas() ?> <?php include_metas() ?> <?php include_title() ?> <link rel="shortcut icon" href="/favicon.ico" /> <?php if (has_slot('gmapheader')): ?> <?php include_slot('gmapheader') ?> <?php endif; ?> </head>
- sampleSuccess.php
<?php slot('gmapheader') ?> <script src="http://maps.google.com/maps?file=api&v=2&key=foobar" type="text/javascript"></script> <?php end_slot() ?> <div id="map" style="width:640px; height:480px"></div> /* javascriptを書く */