定制 ropendev/platesattributes 二次开发

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

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

ropendev/platesattributes

最新稳定版本:1.0.1

Composer 安装命令:

composer require ropendev/platesattributes

包简介

[Plates Extension] Transform an array in html tag attributes.

README 文档

README

This package is not maintened anymore (but still works) : Use https://github.com/PiedWeb/RenderHtmlAttribute

Plates Extension : Render html tag attributes

Quality Score SensioLabsInsight Build Status

This package is an extension for the template engine Plates.

Two features for the same goal Manipulate html tag attributes via PHP array :

  • $this->attr(array $attributes) transform an array in html tag attributes
  • $this->mergeAttr(array $arr1, array $arr2, [array $arr3, ...]) merge multiple array without loosing values (Eg. : ['class' => 'main'] + ['class' => 'content'] = ['class' => 'main content'])

##Table of contents

##Usage

/* Template Init */
$templateEngine = new \League\Plates\Engine('app/views');

/* Load this extension */
$templateEngine->loadExtension(new \rOpenDev\PlatesExtension\Attributes());

$this->render('test', ['attributes' => ['class' => 'content']]);

In your app/views/test.php template file:

<?php
$defaultAttributes = ['class' => 'main'];
$attributes        = isset($attributes) ? $this->mergeAttr($defaultAttributes, $attributes) : $defaultAttributes;
?>
<div<?=$this->attr($attributes)?>>Hello World !</div>

Will render:

<div class="main content">Hello World !</div>

Installation

composer require ropendev/platesattributes

Requirements

Stand alone extension.

See composer.json file.

Contributing

See CONTRIBUTING.md file.

Contributors

License

MIT (see the LICENSE file for details)

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-15