07/10/31 10:44:11
>>242
$file = $tpl_dir. 'template.tpl';
if (!file_exists($file)) {
$contents = preg_replace(
array(
'/^<\?xml/',
'/#\{(.*?)\}/',
'/%\{(.*?)\}/'
),
array(
'<<?php ?>?xml',
'<?php echo $1; ?>',
'<?php echo htmlspecialchars($1); ?>'
),
file_get_contents($file)
);
file_put_contents($file, $contents);
}
include $file;
こんな感じか。変数がかぶるとかなら関数作って渡せばいいだけやね。
うちだと、symfonyのviewの部分に、こんな感じのを作って入れてる。
(といってもそのままじゃなくて、<input />等のタグを、ヘルパに変換して代入する処理も入れてる訳だけど。