快速使用说明
模板引擎可以单独使用, 只要引入单个文件即可使用, api也很简单, 只有assign, display, fetch,compiler, extend 就完成了.
ThinkPHP 5中可以使用composer安装驱动
在命令行下面,切换到你的web根目录下面并执行下面的命令:
composer require topthink/think-angular
使用和配置
<?php use thinkangularAngular; require "../src/Angular.php"; // 配置 $config = [ "debug" => true, // 是否开启调试, 开启调试会实时生成缓存 "tpl_path" => "./view/", // 模板根目录 "tpl_suffix" => ".html", // 模板的后缀 "tpl_cache_path" => "./cache/", // 模板缓存目录 "tpl_cache_suffix" => ".php", // 模板缓存后缀 "directive_prefix" => "php-", // 指令前缀 "directive_max" => 10000, // 指令的最大解析次数 ]; // 实例化 $view = new Angular($config); // 数据 $data = array( "title" => "Hello PHP Angular", "list" => array( array("name" => "name_1", "email" => "email_1@qq.com"), array("name" => "name_2", "email" => "email_2@qq.com"), array("name" => "name_3", "email" => "email_3@qq.com"), array("name" => "name_4", "email" => "email_4@qq.com"), array("name" => "name_5", "email" => "email_5@qq.com"), ), ); // 向模板引擎设置数据 $view->assign($data); // 输出解析结果 $view->display("index"); // 获取编译解析html结果 $html = $view->fetch("index"); // 获取模板编译后的php代码 $php = $view->compiler("index");