1. base.html
<!DOCTYPE html>
<html>
<head>
<title>base</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div php-block="left">这里是left, 会被替换</div>
<div php-block="right">这里是right, 会被替换</div>
<div php-block="bottom">这里是bottom, 会被替换</div>
</body>
</html>
2. index.html
<div php-extends="common/base"></div>
<div php-block="left">
网页主体
</div>
<div php-block="right">
侧边栏推荐
<ul>
<li php-repeat="[1,2,3,4,5] as $i">列表 {$i}</li>
</ul>
</div>
<div php-block="bottom">
版权所有 {$username}
</div>
> 这样模板引擎调用解析 index.html的时候会把对应的block合并到base.html中, 实现模板的继承
解析结果
<!DOCTYPE html>
<html>
<head>
<title>base</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div >
网页主体
</div>
<div >
侧边栏推荐
<ul>
<?php foreach ([1,2,3,4,5] as $i) { ?><li >列表 <?php echo $i; ?></li><?php } ?>
</ul>
</div>
<div >
版权所有 <?php echo $username; ?>
</div>
</body>
</html>
</div>