All Projects → hex-ci → hulk-template

hex-ci / hulk-template

Licence: MIT License
为 CodeIgniter 框架增加视图继承功能,不改变原有视图编写方式,无缝增加视图继承功能。

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to hulk-template

ForgeIgniter-CI-3.x
Friendly open source CMS forged on Codeigniter 3
Stars: ✭ 26 (+52.94%)
Mutual labels:  codeigniter
ParkCatcher
Find a free parking in the nearest residential street when driving in Montréal. A Montréal Open Data project.
Stars: ✭ 32 (+88.24%)
Mutual labels:  codeigniter
vue-php-admin
RBAC通用角色权限管理系统, 前后端分离架构, 基于 vue-element-admin 和 PHP CodeIgniter RESTful 实现
Stars: ✭ 4 (-76.47%)
Mutual labels:  codeigniter
gisportal
GIS portal and Administration part of Extended QGIS Web Client
Stars: ✭ 19 (+11.76%)
Mutual labels:  codeigniter
shaven
DOM building utility & Template engine based on JsonML + syntax sugar
Stars: ✭ 66 (+288.24%)
Mutual labels:  template-engine
lua-resty-aries
openresty and lua multi-function template
Stars: ✭ 47 (+176.47%)
Mutual labels:  template-engine
pyxl4
Extend Python syntax with HTML.
Stars: ✭ 68 (+300%)
Mutual labels:  template-engine
kirby-blade
Enable Laravel Blade Template Engine for Kirby 3
Stars: ✭ 20 (+17.65%)
Mutual labels:  template-engine
cat
CAT is a computer-based online test application powered by Codeigniter, jquery. Simple and easy to use
Stars: ✭ 72 (+323.53%)
Mutual labels:  codeigniter
coding-standard
Official Coding Standards for CodeIgniter
Stars: ✭ 24 (+41.18%)
Mutual labels:  codeigniter
yqdoc
基于语雀API开发的文档系统
Stars: ✭ 64 (+276.47%)
Mutual labels:  codeigniter
view
Template Engine For AdonisJS
Stars: ✭ 13 (-23.53%)
Mutual labels:  template-engine
idris-tmustache
Total Logic-Less Templating Library
Stars: ✭ 12 (-29.41%)
Mutual labels:  template-engine
article-translation
CodeIgniter article translation. CodeIgniter 文章翻译项目。
Stars: ✭ 25 (+47.06%)
Mutual labels:  codeigniter
kotlin-html
A library to generate HTML in Kotlin.
Stars: ✭ 23 (+35.29%)
Mutual labels:  template-engine
korte
Kotlin cORoutines Template Engine for Multiplatform Kotlin
Stars: ✭ 69 (+305.88%)
Mutual labels:  template-engine
typesafe-templates
Template engine that leverages JSX to generate JavaScript code from TypeScript code files rather than text templates.
Stars: ✭ 27 (+58.82%)
Mutual labels:  template-engine
yatpl
Yet Another Template Engine 🚀
Stars: ✭ 14 (-17.65%)
Mutual labels:  template-engine
moustachu
Mustache templating for Nim
Stars: ✭ 58 (+241.18%)
Mutual labels:  template-engine
MulleScion
🌱 A modern template engine for Objective C
Stars: ✭ 14 (-17.65%)
Mutual labels:  template-engine

CodeIgniter 视图继承类库

为 CodeIgniter 框架增加视图继承功能,不改变原有视图编写方式,无缝增加视图继承功能。

安装方法

  1. Hulk_template.php 放到 ./application/libraries 目录下
  2. 创建目录 ./application/third_party/hulk_template/views,如果目录不存在则要自己手动逐级创建。
  3. ./application/third_party/hulk_template/views 目录设为可写,Linux 下一定要保证 Apache 或 Nginx 对这个目录可写。

例子

父视图 ./application/views/parent_message.php :

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Welcome to <# block title #>CodeIgniter<# /block #></title>
</head>
<body>
    <h1>Welcome to <# block title #>CodeIgniter<# /block #>!</h1>
</body>
</html>

子视图 ./application/views/welcome_message.php :

<# extends parent_message #>

<# block title #>CI Chinese<# /block #>

控制器:

class Welcome extends CI_Controller {

    public function index()
    {
        // 载入类库
        $this->load->library('hulk_template');

        // 加载子视图。这里可直接代替 $this->load->view() 的功能。
        $this->hulk_template->parse('welcome_message');
    }
}

视图继承语法

实现视图继承的标签采用 <# 开头,#> 结尾。例如:<# block #>

extends 标签

<# extends 视图路径 #>

例如 <# extends welcome/test #>

这里指的是从 ./application/views/welcome/test.php 这个视图继承。

注意:extends 标签必须在视图文件首行首字母位置。另外这个标签不需要结束标签。

block 标签

<# block 名称 #>内容...<# /block #>

在父视图中使用 block 代表定义一个名为“名称”的 block。

在子视图中使用 block 代表替换父视图中同名的 block。

parent 标签

<# block 名称 #>
  <# parent #>

  内容...
<# /block #>

parent 标签只能在 block 标签中使用,功能是把父模板相同 block 名称的内容放到当前 block 中 parent 所在位置。

child 标签

<# block 名称 #>
  <# child #>

  内容...
<# /block #>

child 标签只能在 block 标签中使用,功能是把子模板相同 block 名称的内容放到当前 block 中 child 所在位置。

slot 标签

<# block 名称 #>
  <# slot 插槽名称 #>
    内容
  <# /slot #>

  内容...
<# /block #>

slot 标签只能在 block 标签中使用。

slot 标签是用于在父模板中定义一些插槽位置,子模板会替换父模板相同插槽名称所在位置的内容。

call 标签

<# block 名称 #>
  <# call 其它block名称 #>
    <# slot 插槽名称 #>
      内容
    <# /slot #>
  <# /call #>

  内容...
<# /block #>

call 用于把当前文件其它 block 名称(支持最近一级父模板)的内容,替换 call 所在位置的内容。其中 slot 的意义与上节一样,会替换相应的内容。

use 标签

<# block 名称 #>
  <# use 其它block名称 #>

  内容...
<# /block #>

use 是简化版的 call,如果不需要替换 slot 的内容,可以直接使用 use

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].