{"id":25470110,"url":"https://github.com/thinkphp/php-template-engine","last_synced_at":"2026-03-07T16:03:36.759Z","repository":{"id":66903083,"uuid":"1392593","full_name":"thinkphp/php-template-engine","owner":"thinkphp","description":"PHP lightweight Template Engine  with same interface as Savant3 and Smarty.","archived":false,"fork":false,"pushed_at":"2011-02-21T12:23:38.000Z","size":106,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-09T00:23:49.427Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://thinkphp.ro/apps/php-hacks/php-template-engine/demos/demo4Twitter2/go.php","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thinkphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-02-21T11:44:33.000Z","updated_at":"2025-01-22T20:10:25.000Z","dependencies_parsed_at":"2023-02-20T14:00:22.411Z","dependency_job_id":null,"html_url":"https://github.com/thinkphp/php-template-engine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thinkphp/php-template-engine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2Fphp-template-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2Fphp-template-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2Fphp-template-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2Fphp-template-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinkphp","download_url":"https://codeload.github.com/thinkphp/php-template-engine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2Fphp-template-engine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30221193,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T14:02:48.375Z","status":"ssl_error","status_checked_at":"2026-03-07T14:02:43.192Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-18T08:31:56.649Z","updated_at":"2026-03-07T16:03:36.738Z","avatar_url":"https://github.com/thinkphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"PHP Template Engine\n===================\n\nVery simple template engine for PHP5 with same interface as Savant3 and Smarty. Assign content to engine, then display a template file.\n\nHow to use\n----------\n\n    //path/to/templates\n    $path = 'templates/';\n\n    //create an object\n    $tpl = new Template($path);  \n\n    //assign some content\n    $tpl-\u003eassign('title','PHP Template Engine');\n\n    //display the template\n    $tpl-\u003edisplay('header.tpl.php');\n    //create an object Template\n\n    $body = new Template($path);\n    //create an object Template\n\n    $a = new Template($path);\n\n    //assign some content\n    //this would typically came froma database or other source,\n    //but we'll use static value for the purpose of this example\n    $a-\u003eassign('result', $result);\n    $body-\u003eassign('label','Username: ');\n    //assign from \n    $body-\u003eassign('tweets', $a-\u003efetch('content.tweets.tpl.php'));\n    //also, create an object Template\n    $footer = new Template($path);\n    //assigb static value\n    $footer-\u003eassign('written','thinkphp');\n    $footer-\u003eassign('download','#');\n    //assign values from another fetching template.\n    $body-\u003eassign('footer',$footer-\u003efetch('footer.tpl.php'));\n    //display the template\n    $body-\u003edisplay('body.tpl.php');\n\n\nIt can be used with the following templates:\n\n\n    \u003c!-- header.tpl.php --\u003e\n\n    \u003c!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"\u003e\n    \u003chtml\u003e\n    \u003chead\u003e\n    \u003cmeta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\" /\u003e\n    \u003ctitle\u003e\u003c?php echo$title;?\u003e\u003c/title\u003e\n    \u003cstyle type=\"text/css\"\u003e\n    /* do something CSS */\n    \u003c/style\u003e\n    \u003c/head\u003e\n\n\n    \u003c!-- content.tweets.tpl.php --\u003e\n    if($result \u0026\u0026 is_array($result)) {\n\n     $out = '\u003col id=\"timeline\" class=\"statuses\"\u003e';\n     $header = '\u003cli\u003e\u003cimg src=\"'.$result[0]['user']['profile_image_url'].'\"\u003e'.\n                  '\u003cdiv\u003e\u003cstrong\u003e@'.$result[0]['user']['screen_name'].'\u003c/strong\u003e\u003c/div\u003e'.\n                  '\u003cdiv\u003e'.$result[0]['user']['location'].'\u003c/div\u003e'.\n                  '\u003cdiv\u003e\u003ca href=\"'.$result[0]['user']['url'].'\"\u003e'.$result[0]['user']['url'].'\u003c/a\u003e\u003c/div\u003e'.\n                  '\u003cdiv\u003e'.$result[0]['user']['description'].'\u003c/div\u003e'.\n                  '\u003c/li\u003e';\n\n     $out .= $header;\n     foreach($result as $r) {\n     $out .= '\u003cli\u003e';\n     $out .= '\u003cspan class=\"status-body\"\u003e';\n     $out .= '\u003cspan class=\"status-content\"\u003e';\n     $out .= '\u003cspan class=\"status-entry\"\u003e';\n     $out .= ($r['text']);  \n     $out .= '\u003c/span\u003e';\n     $out .= '\u003c/span\u003e';\n     $out .= '\u003cspan class=\"meta entry-meta\"\u003e';\n     $out .= $r['created_at'];\n     $out .= '\u003c/span\u003e';\n     $out .= '\u003c/li\u003e';\n     }\n     $out .= '\u003c/ol\u003e';\n   \n     } else {\n       $out = 'No found results.';\n     }\n     //output the result\n     echo$out;\n   \n\n     \u003c!-- body.tpl.php --\u003e\n\n     \u003cbody\u003e\n     \u003cdiv id=\"logo\"\u003e\u003ca href=\"#\"\u003eTwitter\u003c/a\u003e\u003c/div\u003e\n     \u003cform id=\"f\" name=\"f\"\u003e\n           \u003clabel for=\"username\"\u003e\u003c?php echo$label;?\u003e\u003c/label\u003e\u003cinput type=\"text\" id=\"username\" name=\"username\" value=\"\u003c?php echo$_GET['username'];?\u003e\"/\u003e\u003cinput type=\"submit\" value=\"Grab\"\u003e\n     \u003c/form\u003e  \n     \u003cdiv id=\"content_tweets\"\u003e\u003c?php echo$tweets; ?\u003e\u003c/div\u003e\n     \u003c?php echo$footer;?\u003e\n     \u003c/body\u003e\n     \u003c/html\u003e\n\n     \u003c!-- footer.tpl.php --\u003e\n\n     \u003cdiv id=\"ft\"\u003e\u003cp\u003eWritten by @\u003ca href=\"http://twitter.com/thinkphp\"\u003e\u003c?php echo$written;?\u003e\u003c/a\u003e | download on \u003ca href=\"\u003c?php echo$download;?\u003e\"\u003eGitHub\u003c/a\u003e\u003c/p\u003e\u003c/div\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkphp%2Fphp-template-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinkphp%2Fphp-template-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkphp%2Fphp-template-engine/lists"}