定制 alexkuusk/malli 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alexkuusk/malli

Composer 安装命令:

composer require alexkuusk/malli

包简介

Slim PHP template parser

README 文档

README

A simple and lightweight PHP templating engine using few custom tags that all are translated into pure PHP. PHP is also allowed inside templates, just be aware of the scopes. Template blocks are compiled into PHP functions and functions are called and their output captured.

Possibility to add custom tags, for example translation code. That code's output can be turned into static and saved along with PHP code, so that heavy translating functions are not called every page load. Supports multilanguage and multisite, just pass language parameter and use dynamic path with another set of templates ('path' => '../tpl/' . $_SERVER['SERVER_NAME'] . '/').

Blocks can be nested inside blocks.

Requires PHP version 8.2+

Setup

See Example folder for more complex examples

composer install alexkuusk/malli

minimal

require_once '../vendor/autoload.php';

use Alexkuusk\Malli\Malli;

echo (new Malli([
    '_params' => [
        'path' => '../tpl/',
        'file' => 'index.tpl',
        'block' => 'index', //if omitted, file name without extension is used
    ],
    '_data' => [
        'title' => 'Template test',
        'books' => [
            'One',
            'two',
        ]
    ]));

index.tpl

{{ BLOCK:index }}
<html>
<head>
    <title>{{ $title }}</title>
</head>
<body>
<table border=1>
{{ FOREACH $books as $k => $title }}
    <tr>
        <td>{{ $k + 1 }}</td>
        <td>{{ htmlspecialchars($title) }}</td>
    </tr>
{{ /FOREACH }}
</table>
</body>
</html>
{{ /BLOCK:index }}

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-02-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固