Smartyで文字列テンプレート
テンプレートファイルつくるほどでもないってときに。
register_resource()すればいいのか。
http://www.smarty.net/manual/ja/api.register.resource.php
require 'Smarty/Smarty.class.php'; $s = new Smarty; $s->template_dir = dirname(__FILE__); $s->compile_dir = dirname(__FILE__); function string_get_template ($tpl_name, &$tpl_source, &$smarty_obj) { $tpl_source = $tpl_name; return true; } function string_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) { return true; } function string_get_secure($tpl_name, &$smarty_obj) { return true; } function string_get_trusted($tpl_name, &$smarty_obj) { } $s->register_resource("string", array("string_get_template", "string_get_timestamp", "string_get_secure", "string_get_trusted")); $template = <<<END konnnitiha! konnnitiha! konnnitiha! konnnitiha! END; $s->display("string:$template");
デフォルトで組み込まれてたらいいのになー