{"id":21925223,"url":"https://github.com/hex-ci/hulk-template","last_synced_at":"2025-04-19T15:47:40.550Z","repository":{"id":21745703,"uuid":"25067558","full_name":"hex-ci/hulk-template","owner":"hex-ci","description":" 为 CodeIgniter 框架增加视图继承功能，不改变原有视图编写方式，无缝增加视图继承功能。","archived":false,"fork":false,"pushed_at":"2017-11-22T09:47:17.000Z","size":43,"stargazers_count":17,"open_issues_count":0,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T09:34:08.572Z","etag":null,"topics":["codeigniter","php","template-engine"],"latest_commit_sha":null,"homepage":"http://codeigniter.org.cn/forums/thread-19488-1-1.html","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hex-ci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-11T07:15:41.000Z","updated_at":"2022-03-03T11:21:50.000Z","dependencies_parsed_at":"2022-08-17T18:15:27.941Z","dependency_job_id":null,"html_url":"https://github.com/hex-ci/hulk-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hex-ci%2Fhulk-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hex-ci%2Fhulk-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hex-ci%2Fhulk-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hex-ci%2Fhulk-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hex-ci","download_url":"https://codeload.github.com/hex-ci/hulk-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249730570,"owners_count":21317327,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["codeigniter","php","template-engine"],"created_at":"2024-11-28T21:17:37.742Z","updated_at":"2025-04-19T15:47:40.532Z","avatar_url":"https://github.com/hex-ci.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CodeIgniter 视图继承类库\n\n 为 CodeIgniter 框架增加视图继承功能，不改变原有视图编写方式，无缝增加视图继承功能。\n\n## 安装方法\n\n1. 把 `Hulk_template.php` 放到 `./application/libraries` 目录下\n2. 创建目录 `./application/third_party/hulk_template/views`，如果目录不存在则要自己手动逐级创建。\n3. 把 `./application/third_party/hulk_template/views` 目录设为可写，Linux 下一定要保证 Apache 或 Nginx 对这个目录可写。\n\n## 例子\n\n父视图 ./application/views/parent_message.php :\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003ctitle\u003eWelcome to \u003c# block title #\u003eCodeIgniter\u003c# /block #\u003e\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003ch1\u003eWelcome to \u003c# block title #\u003eCodeIgniter\u003c# /block #\u003e!\u003c/h1\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n子视图 ./application/views/welcome_message.php :\n\n```html\n\u003c# extends parent_message #\u003e\n\n\u003c# block title #\u003eCI Chinese\u003c# /block #\u003e\n```\n\n控制器：\n\n```php\nclass Welcome extends CI_Controller {\n\n    public function index()\n    {\n        // 载入类库\n        $this-\u003eload-\u003elibrary('hulk_template');\n\n        // 加载子视图。这里可直接代替 $this-\u003eload-\u003eview() 的功能。\n        $this-\u003ehulk_template-\u003eparse('welcome_message');\n    }\n}\n```\n\n## 视图继承语法\n\n实现视图继承的标签采用 \u003c# 开头，#\u003e 结尾。例如：`\u003c# block #\u003e`\n\n### extends 标签\n\n```\n\u003c# extends 视图路径 #\u003e\n```\n\n例如 `\u003c# extends welcome/test #\u003e`\n\n这里指的是从 `./application/views/welcome/test.php` 这个视图继承。\n\n注意：`extends` 标签必须在视图文件首行首字母位置。另外这个标签不需要结束标签。\n\n### block 标签\n\n```\n\u003c# block 名称 #\u003e内容...\u003c# /block #\u003e\n```\n\n在父视图中使用 block 代表定义一个名为“名称”的 block。\n\n在子视图中使用 block 代表替换父视图中同名的 block。\n\n### parent 标签\n\n```\n\u003c# block 名称 #\u003e\n  \u003c# parent #\u003e\n\n  内容...\n\u003c# /block #\u003e\n```\n\n`parent` 标签只能在 `block` 标签中使用，功能是把父模板相同 block 名称的内容放到当前 block 中 parent 所在位置。\n\n### child 标签\n\n```\n\u003c# block 名称 #\u003e\n  \u003c# child #\u003e\n\n  内容...\n\u003c# /block #\u003e\n```\n\n`child` 标签只能在 `block` 标签中使用，功能是把子模板相同 block 名称的内容放到当前 block 中 child 所在位置。\n\n### slot 标签\n\n```\n\u003c# block 名称 #\u003e\n  \u003c# slot 插槽名称 #\u003e\n    内容\n  \u003c# /slot #\u003e\n\n  内容...\n\u003c# /block #\u003e\n```\n\n`slot` 标签只能在 `block` 标签中使用。\n\n`slot` 标签是用于在父模板中定义一些插槽位置，子模板会替换父模板相同插槽名称所在位置的内容。\n\n### call 标签\n\n```\n\u003c# block 名称 #\u003e\n  \u003c# call 其它block名称 #\u003e\n    \u003c# slot 插槽名称 #\u003e\n      内容\n    \u003c# /slot #\u003e\n  \u003c# /call #\u003e\n\n  内容...\n\u003c# /block #\u003e\n```\n\n`call` 用于把当前文件其它 block 名称（支持最近一级父模板）的内容，替换 call 所在位置的内容。其中 `slot` 的意义与上节一样，会替换相应的内容。\n\n### use 标签\n\n```\n\u003c# block 名称 #\u003e\n  \u003c# use 其它block名称 #\u003e\n\n  内容...\n\u003c# /block #\u003e\n```\n\n`use` 是简化版的 `call`，如果不需要替换 `slot` 的内容，可以直接使用 `use`。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhex-ci%2Fhulk-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhex-ci%2Fhulk-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhex-ci%2Fhulk-template/lists"}