millancore/view-element 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

millancore/view-element

最新稳定版本:v0.1

Composer 安装命令:

composer require millancore/view-element

包简介

Template system without configuration or dependencies.

README 文档

README

This is a library for creating modular views in PHP, without configuration or dependencies.

  • Slot
  • Render
  • Filters

Install

 composer require millancore/view-element

Slot

You can create a template without defining the template body, it is passed by the view that will use it.

You can also make use of the helper functions vxSlot(), vxStart(...), vxEnd(), which will make it easier for you to define components with fewer lines of code.

template_list.php

<ul id="<?= $id ?? '' ?>">
    <?= \Vx\View::slot() ?>
</ul>

view.php

<?php Vx\View::start('template_list.php', [ 'id' => 'list']) ?>
    <li>Test parent element</li>
    <?php Vx\View::start('template_list.php', ['id' => 'sublist']) ?>
        <li>Test Child element</li>
        <li>Test Child element</li>
    <?php Vx\View::end(); ?>
    <li>Test Parent element</li>
<?php Vx\View::end(); ?>

or using helpers functions

<?php VxStart('template_list.php', [ 'id' => 'list']) ?>
    <li>Test parent element</li>
    <?php VxStart('template_list.php', ['id' => 'sublist']) ?>
        <li>Test Child element</li>
        <li>Test Child element</li>
    <?php VxEnd(); ?>
    <li>Test Parent element</li>
<?php VxEnd(); ?>

Html

<ul id="list">
    <li>Test parent element</li>
    <ul id="sublist">
        <li>Test Child element</li>
        <li>Test Child element</li>
    </ul>
    <li>Test Parent element</li>
</ul>

Config (optional)

This will allow you to define a path where all the views will be and not have to type .php as it will be added automatically.

bootstrap.php
$viewResolver = Vx\Resolver::getInstance();

$viewResolver->config(new Vx\Config([
     'viewDir' => __DIR__ . DIRECTORY_SEPARATOR  . 'views',
     'extension' => false
]));

Filters

the filters are very simple, they allow you to add registering methods that modify.

bootstrap.php
$viewResolver = Vx\Resolver::getInstance();

$viewResolver->addFilter('upper', fn($string) => strtoupper($string));

Use them

<h1> <?= VxFilter('mi name', 'upper') ?> </h1> <!-- MI NAME -->

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固