Skip to content

Instantly share code, notes, and snippets.

@jinwei233
Created September 17, 2011 12:40
Show Gist options
  • Save jinwei233/1223907 to your computer and use it in GitHub Desktop.
Save jinwei233/1223907 to your computer and use it in GitHub Desktop.
PHP 模板 例子
<?php
require_once("../../app/tpl-engine/Haanga.php");
$str = "
Hi {{name}}! Welcome to Koubei.com
{# foreach #}
{% for n in numbers %}
<div>{{n}}</div>
{% endfor %}
";
$tpl = Haanga::compile($str);
$data["name"] = "tom";
$data["numbers"] = array("1"=>"one","2"=>"two");
echo $tpl($data);
/////////////////////////////模板////////////////////////////////
Haanga::configure(array(
'template_dir'=>"./",
"cache_dir"=>"./cached",
));
Haanga::Load("tpl.html",$data);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment