Score
0
Watch 8 Star 17 Fork 2

阿债 / templaterPHPMIT

Join us
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
一个简单够用的PHP模板,连注释一起200行左右。 spread retract

Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

templater

一个简单够用的PHP模板,连注释一起200行左右。

使用方法:

在控制器的PHP代码中

<?php
$tpl = new MY_Templater();
$tpl->addGlobal('title ', 'Test Page');
$tpl->addFrameFile('views/test.php');
echo $tpl->render(['a'=>1, 'b'=>2]);
?>

两个模板文件 入口 views/test.php

<?php $this->extendTpl('layout.php'); ?>

<?php $this->blockStart('title'); ?>
  <title><?= $title ?></title>
<?php $this->blockEnd(); ?>

<?php $this->blockStart('content'); ?>
  <div>a: <?= $a ?></div>
  <div>b: <?= $b ?></div>
<?php $this->blockEnd(); ?>

布局 views/layout.php

<html>
<head>
  <?= $this->block('title') ?>
</head>
<body>
  <?= $this->block('content') ?>
</body>
</html>

Comments ( 1 )

Sign in for post a comment

PHP
1
https://gitee.com/azhai/templater.git
git@gitee.com:azhai/templater.git
azhai
templater
templater
master

Help Search

205735 778617b6 1899542 205747 347fc4a1 1899542